为了账号安全,请及时绑定邮箱和手机立即绑定

mysqli多条查询语句执行出错

<?php

require_once ('connect.php');

$sql="select * from newsreport.news;";

$sql.="select id,username,age from user;";

$mysqli->multi_query($sql);

if($mysqli->multi_query($sql)){

    do{

        if($res=$mysqli->store_result()){ //use_result()或store_result()得到查询的结果集

            $rows[]=$res->fetch_all(MYSQLI_ASSOC);

            $res->free();

            //$res->free_result();

        }

    }while($mysqli->more_results()&&$mysqli->next_result());//more_result()检测是否有更多的结果集,next_result()将结果集指针向下移动一位

}else{

    echo $mysqli->error;

}

print_r($rows);

$mysqli->close();

?>

结果显示:

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

正在回答

1 回答

太粗心了,多写了一条$mysqli->multi_query($sql);

1 回复 有任何疑惑可以回复我~

举报

0/150
提交
取消

mysqli多条查询语句执行出错

我要回答 关注问题
微信客服

购课补贴
联系客服咨询优惠详情

帮助反馈 APP下载

慕课网APP
您的移动学习伙伴

公众号

扫描二维码
关注慕课网微信公众号