Mysql has Gone away when running 'DELETE' using PHP connection

Asked

Viewed 32 times

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:

MYSQL - SHOW FULL PROCESSLIST

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.

  • 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.

  • the function mysql_query was deprecated in PHP 5.5 and removed in PHP 7.0 . Use the extension mysqli.

  • @Augustovasques Even switching the system connection to PDO, the error persists.

  • Check the connection to see if it is active.

  • @Augustovasques The connection dies because it exceeds 40 seconds of waiting for the return.

  • 2

    Check before delete and after delete use mysqli_error() to print the error message.

  • Show us more of the code! :)

  • @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.

Show 4 more comments
No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.