Recently I made a change in the table and after that SELECT
and INSERT INTO
stopped working.
At first INSERT INTO
could not include data in the last column that includes (centid), it returned column 'centid' cannot be null
, however the value was being passed (to solve this for now I started to let this column accept NULL
and I do the UPDATE
soon after).
In addition to this problem with INSERT, a simple SELECT on this table stopped working through PHP.
In all cases I checked if there were empty variables and in all cases nothing is being passed, including in the code below, the variable $viagemid
is passing the value.
PHP:
$despesas = array();
$sql = "SELECT * FROM 'despesas' WHERE 'viagemid' = '".$viagemid."'";
$query = $mysqli->query($sql);
$count_desp = mysqli_num_rows($query);
$result = mysqli_fetch_row($query);
while($row =mysqli_fetch_assoc($query)){
array_push($despesas, $row);
}
In this code specifically, I enabled mysqli_report(MYSQLI_REPORT_ALL);
and the return was:
Fatal error: Uncaught exception 'mysqli_sql_exception' with message 'No index used in query / prepared statement SELECT * FROM
despesas
WHEREviagemid
=' 1041 '' in C: \ Users \ fchagas \ Documents \ EasyPHP-Devserver -16.1 \ eds-www \ edit_password.php: 146 Stack trace: # 0 C: \ Users \ SELECT * FROM '...') # 1 {main} thrown in C: \ Users \ fchagas \ Documents \ EasyPHP-Devserver-16.1 \ eds-www \ edit_viagem.php on line 146
The Apache log (can be useful):
127.0.0.1 - - [21/Feb/2017:21:18:39 -0300] "POST /nova_viagem.php HTTP/1.1" 200 19992
127.0.0.1 - - [21/Feb/2017:21:18:49 -0300] "GET /eds-modules/phpmyadmin4551x170208222435/sql.php?server=1&db=database&table=despesas&pos=0&token=dad73b6308c6b0dd8911a2c3312bf46e&ajax_request=true&ajax_page_request=true&_nocache=1487722729000434776 HTTP/1.1" 200 7204
127.0.0.1 - - [21/Feb/2017:21:18:49 -0300] "GET /eds-modules/phpmyadmin4551x170208222435/index.php?ajax_request=1&recent_table=1&token=dad73b6308c6b0dd8911a2c3312bf46e&no_debug=true&_nocache=1487722729416685739 HTTP/1.1" 200 1567
127.0.0.1 - - [21/Feb/2017:21:18:54 -0300] "GET /listar_viagem.php HTTP/1.1" 200 60541