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

前端 未结 21 2540
庸人自扰
庸人自扰 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:01

    If you either use Buffered or Unbuffered result set for fetching data, first you must simply clear the fetched data from the memory, once you have fetched all the data. As you can't execute another MYSQL procedure on the same connection till you clear the fetched memory. Add this below function right end of your script, so it will solve the problem

    $numRecords->close(); or $numRecords->free(); // This clears the referencing memory, and will be ready for the next MYSQL fetch
    

    Reference from the PHP documentation

提交回复
热议问题