1
When I run the SQL statement delete from proposta_envio_fisico WHERE idProposta = 209940
, my Mysql connection is disabled (mysql has Gone away) after 40 seconds.
When monitoring the execution of this instruction the following result is obtained:
The instruction runs until the time out. But if we try to execute the instruction directly from the Mysql console, it is executed correctly.
My Mysql 'Time Out' setting is set in 40 seconds, but it cannot be changed.
The table in question has only 240 records.
The code that is running in PHP is:
mysql_query('delete from proposta_envio_fisico WHERE idProposta =' . $id, $conexao);
Even by changing the connection to PDO, the same error is returned (mysql has Gone away) when running the application.
idProposta
have Indice? tried to drop or Repair in the table? it seems strange even.– rray
Yes, idProposta is index. The strange thing is that when executed in the console, the query is performed instantly. But with the PHP connection it only gets the status updating.
– Max Porcento
the function mysql_query was deprecated in PHP 5.5 and removed in PHP 7.0 . Use the extension mysqli.
– Augusto Vasques
@Augustovasques Even switching the system connection to PDO, the error persists.
– Max Porcento
Check the connection to see if it is active.
– Augusto Vasques
@Augustovasques The connection dies because it exceeds 40 seconds of waiting for the return.
– Max Porcento
Check before delete and after delete use mysqli_error() to print the error message.
– Augusto Vasques
Show us more of the code! :)
– lalvesoliveira
@Augustovasques Yes, after 40 seconds the connection dies. Precisely because the Mysql set time out is configured for this time. The problem here is that when the SLQ statement is done on the console, it is done in milliseconds, however, when it is sent from the application, the SQL statement reaches the limit of 40 seconds causing the connection to end. The question is not why the connection dies, but rather why the SQL statement takes more than 40 seconds to run when sent from the application.
– Max Porcento