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.