I try to execute a very simple query to delete one row. the "max_allowed_packet" equals "1073741824" that's why I'm confused why I get
Error while sending QUERY packet. PID=2
I select just 25 rows from a table to send their data via sms and sleep(1) after deleting the row.
Query:
$stmt = $db->prepare("select * from sms limit 25");
$stmt->execute();
I loop through rows here and send row data via sms then delete it
$q = $db->prepare("delete from sms where id = '$r[id]'");
$q->execute();
sleep(1)
But sometimes (just sometimes not every time) I get that error and row doesn't get deleted so the sms message is sent so many times to the same user because it's still in the table. Any ideas to solve this?
Thanks in advance.
When you use a pattern like
prepare mysql query a
execute mysql query a
for each row in result set a
prepare mysql query b
execute mysql quer b
you must use a separate db connection for mysql query b. Why? query a can still be using its connection as long as you're reading rows from its result set.