2
I recently made a change to the table and after that SELECT
and INSERT INTO
stopped working.
At first the INSERT INTO
could not include data in the last column that includes (centid), returned column 'centid' cannot be null
, but the value was being passed (to resolve this for now I went on to let this column accept NULL
and do the UPDATE
right away).
Besides this problem with INSERT, a simple SELECT in this table stopped working through PHP.
In all cases I checked if there were empty variables and in all cases nothing is missing, 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 that 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\editar_viagem.php:146 Stack trace: #0 C:\Users\fchagas\Documents\EasyPHP-Devserver-16.1\eds-www\editar_viagem.php(146): mysqli->query('SELECT * FROM `...') #1 {main} thrown in C:\Users\fchagas\Documents\EasyPHP-Devserver-16.1 eds-www editar_viagem.php on line 146
Apache log (may 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
I ask for 2 favors. Execute the command SHOW CREATE TABLE
despesas
and put here. Also put the INSERT SQL that is giving error. These two pieces of information, sometimes for themselves, are sufficient to identify the problem.– Marcio Jalber