这个总是报:Strict Standards: mysqli_next_result(): There is no next result set. Please, call mysqli_more_results()/mysqli::more_results() to check whether to call this function/method in E:\phpStudy\WWW\ceshi\mysqli.php on line 113

来源:3-1 MySQLi针对多条SQL语句的执行

xueqiang

2016-08-30 09:43

public function fetch_more_sql($table1, $table2)

{

$sql  = "SELECT * FROM ".$table1." LIMIT 1; SELECT * FROM ".$table2." LIMIT 1";

if(mysqli_multi_query($this ->db_connect(), $sql))

{

do{

//存储第一个结果集

if($result = mysqli_store_result($this ->db_connect() ))

{

while($row = mysqli_fetch_row($result)){

foreach ($row as $key => $value) {

echo $key;

}

}


mysqli_free_result($result);

}


} while( mysqli_next_result( $this ->db_connect()) && mysqli_more_results($this ->db_connect()) );


}

// print_r($rows);

}



写回答 关注

1回答

  • 和你一起闪耀到世界尽头
    2016-09-10 10:28:08

    入过我没看过的话,你用的一次只能执行一次SQL语句但是你执行了2条。$sql  = "SELECT * FROM ".$table1." LIMIT 1; SELECT * FROM ".$table2." LIMIT 1";

    ,第二不要动态拼装SQL语句,慎防SQL注入,和自己拼写错误,应该用预处理语句,然后绑定参数试试

    和你一起闪耀...

    好吧,我的确看错了

    2016-09-10 11:00:18

    共 1 条回复 >

Duang~MySQLi扩展库来袭

本教程从面向对象和面向过程两个方面为你开启MySQLi学习之旅

28646 学习 · 181 问题

查看课程

相似问题