I’m trying to delete one row of data from a MySQL database (innodb) in a PHP script. But instead of deleting, the PHP script hangs on the query. It’s a very simple delete statement:
`mysqli_query($conn, 'delete from picture where idPicture = "'. $temp . '"');'
If I echo the delete string and paste it into a MySQL query window the statement executes normally. Debugging with xdebug shows me just the same hanging on the above delete statement.
mysqli_error() gives me an output of :
Lock wait timeout exceeded; try restarting transaction
If I try to close the connection, afterwards I get this error:
Warning: mysqli_close() [function.mysqli-close]: Couldn’t fetch mysqli in
I guess that’s normal because the connection timed out.
I also use the same connection for other delete/select statements and they all perform well.
If someone could explain what I’m doing wrong it would be really appreciated.
Lock wait timeout exceeded; try restarting transactionIn other words the table is locked and cannot be accessed. Make sure no other MySQL sessions are accessing this table (there might be some persistent connections hanging for example).
COMMIT/ROLLBACK any other transactions that have anything to do with this table.
Try getting explicit LOCK for deleting.
See more here: http://dev.mysql.com/doc/refman/5.5/en/lock-tables-and-transactions.html