Mysql文档中说明错误: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.
如果你正在使用mysql_use_result()并且在你已经调用了mysql_free_result()之前试图执行新查询。
如果你在mysql_use_result()或mysql_store_result()之间试图执行返回数据的2个查询,它也可能发生。
解决方法就是,检查一下你的脚本中有没有query结果大于1,却用了fetchone的情况。
都改用fetchall是一下。