问题
When I use mysqli_multi_query() with a mass INSERT query, then after the query has run do another query using mysqli_query('SELECT...'), I get "commands out of sync" errors. Does anyone know why this happens?
回答1:
You've to call mysqli_use_result (or mysqli_store_result) after a mysqli_multi_query()
call.
Lower level documentation about this error: http://dev.mysql.com/doc/refman/5.1/en/commands-out-of-sync.html
回答2:
Use mysqli_next_result($db) , after freeing the result set if any . This alone would fix the out of sync issues.
来源:https://stackoverflow.com/questions/3927068/php-5-3-mysqli-multi-query-and-commands-out-of-sync-errors