PHP 5.3: mysqli_multi_query and “commands out of sync” errors

可紊 提交于 2019-12-24 16:49:47

问题


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

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!