Documentation Home
MySQL 5.7 Reference Manual
Related Documentation Download this Manual
PDF (US Ltr) - 37.8Mb
PDF (A4) - 37.8Mb
PDF (RPM) - 36.4Mb
HTML Download (TGZ) - 9.9Mb
HTML Download (Zip) - 9.9Mb
HTML Download (RPM) - 8.6Mb
Man Pages (TGZ) - 209.5Kb
Man Pages (Zip) - 318.7Kb
Info (Gzip) - 3.5Mb
Info (Zip) - 3.5Mb
Excerpts from this Manual

B.5.2.13 Commands out of sync

If you get Commands out of sync; you can't run this command now in your client code, you are calling client functions in the wrong order.

This can happen, for example, if you are using mysql_use_result() and try to execute a new query before you have called mysql_free_result(). It can also happen if you try to execute two queries that return data without calling mysql_use_result() or mysql_store_result() in between.

User Comments
  Posted by Justin Finkelstein on February 17, 2005
I have just identified and resolved a recurring problem with this error when using PHP in FreeBSD 5.3.

If you're using mysql_pconnect and you call that function repeatedly, and then execute queries on that connection, you will receive this error message. This may be due to the way persistent connections are handled in FreeBSD.

The workaround is to use mysql_connect, which does not generate this error message.
  Posted by Jon Stephens on February 23, 2005
It's best to avoid using mysql_pconnect() in any case, as persistent connections are not supported in PHP 5's mysqli extension (to which all PHP/MySQL development will eventually need to be ported), and really aren't of benefit to Web applications.
  Posted by Peter Sierst Nielsen on March 26, 2005
This error just occured coding C using the "mysqlclient include" having multiple instances of the structure:

struct DB {
MYSQL mysql;
MYSQL_RES *result;
unsigned long numRows;
unsigned long numFields;

... and THEN forgetting to call init/connect/select_db on all but one.
Just wasted half an hour :| Hope it's going to be of use for the next person.
Regards, Peter Sierst Nielsen
  Posted by Vyacheslav Brover on September 1, 2009
The problem is avoided if prepared statements with cursors are used:

const unsigned long type = (unsigned long) CURSOR_TYPE_READ_ONLY;
mysql_stmt_attr_set (stmt, STMT_ATTR_CURSOR_TYPE, (void*) &type);

Sign Up Login You must be logged in to post a comment.