出现错误“命令不同步,您无法立即运行命令".在mysql/php中执行存储过程时 [英] Getting error "Commands out of sync, you can't run the command now" while executing a stored procedure in mysql/PHP

查看:162
本文介绍了出现错误“命令不同步,您无法立即运行命令".在mysql/php中执行存储过程时的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我为一个表编写了一个存储过程,之后我在php函数中执行对同一表的查询,但是我遇到了错误:

I have written a stored procedure for a table, and after that i am executing queries for same table in php function, But i am getting error :

Error in db : Commands out of sync, you can't run the command now..

我尝试了mysqli:multi_query而不是mysqli:query,但是我得到了空输出. 谁能帮我解决这个问题.

I tried mysqli: multi_query also instead of mysqli:query, but i got null output. Can anyone please help me to sort out this problem.

P.S:存储过程按预期工作,并且查询也正确..但是一起返回错误.

P.S : stored proceure is working as expected and query are also correct.. but together it returns the error.

推荐答案

您必须消耗所有选择,然后导航至下一个结果

You have to consume all selects, and navigate to next result

$sql="";
if (mysqli_multi_query($link, $sql)) {
    do {
        if ($result = mysqli_store_result($link)) {
            while ($row = mysqli_fetch_array($result)) {
                array_push($arrows,$row);
            }
            mysqli_free_result($result);
        }
    } while (mysqli_next_result($link));
}

这篇关于出现错误“命令不同步,您无法立即运行命令".在mysql/php中执行存储过程时的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆