Commands out of sync; you can't run this command now
The "Commands out of sync; you can't run this command now" error in PHP usually occurs when you have called a MySQL function in an incorrect order.
This error occurs because MySQL has a command buffer that needs to be used in a specific order, and when you try to execute a command out of order, it results in this error.
Here are a few things you can try to fix this error:
- Make sure that you are calling
mysql_query()only once for each SQL statement. - Make sure that you are calling
mysql_use_result()ormysql_store_result()for everySELECTstatement before calling any other MySQL function. - If you are using
mysql_use_result(), make sure to callmysql_free_result()after you have finished processing the result set.
I hope this helps! Let me know if you have any questions.