I have made a php script which just executes 3 queries.
1st query gets only 1 record.
2nd query is suppose to get a max of 500 records (LIMIT 500 is used)
3rd query is used to update 1 record.
On 3rd query I get: MySQL server has gone away.
Why this is happening ? What to do to fix it ?
Are you getting any errors from either PHP or MySQL?
The last query that is suppose to update the record fails and when i used mysql_error() to see the error i got that else there are no errors of any types and all is working fine, but if this last query does'nt works then my script also fails coz it will next time produce wrong results.
Does the 3rd query work ok when executed via phpmyadmin or the mysql console?
Yes i tried it in phpmyadmin and it works absolutely fine. Its a very simple update query which is updating 2 cols with 1 where clause.
echo the 3rd query that php is sending to MySQL, is there anything which stands out as not being right?
I already added the debug mode to it..and all queries are fine. This error message i came to see when i was debugging the script. The query is fine and i copied it when i was debugging and ran it in phpmyadmin and it executed fine. But in script it gave me that error.
Basically the first query gets the details in 1 single record out of 2-3 records in a table (LIMIT 1 is used)
then 2nd query gets 500 records based on the first query result and processes the information which is nothing to do with db (LIMIT 500 used)
A while and mysql_fetch_array based loop is used to process the info.
then 3rd query's (which is failing) job is to update the counter to the last record we got in the 2nd query (LIMIT 1 used). And this is where the error is happening.
first query gets us the last id number that was processed, say we get: 500
then 2nd query is used to get records beyond 500 till next 500. So we get from 501 to 1000.
and 3rd query's job is to update the id number of last processed record in the db i.e set last id number = 1000.
Thats it. Simple but failing at the end. What i am done now is put the lines to re-connect to the database.. i hope this will resolve the issue but i wont know till tommorow.