Commands out of sync; you can't run this command now

前端 未结 21 2533
庸人自扰
庸人自扰 2020-11-21 11:35

I am trying to execute my PHP code, which calls two MySQL queries via mysqli, and get the error \"Commands out of sync; you can\'t run this command now\".

Here is th

21条回答
  •  轻奢々
    轻奢々 (楼主)
    2020-11-21 12:02

    You can't have two simultaneous queries because mysqli uses unbuffered queries by default (for prepared statements; it's the opposite for vanilla mysql_query). You can either fetch the first one into an array and loop through that, or tell mysqli to buffer the queries (using $stmt->store_result()).

    See here for details.

提交回复
热议问题