Warning: mysqli_multi_query() expects parameter 1 to be mysqli
微wx笑
2023-01-06【运维日志】
2
0关键字:
php mysql
当使用的数据库连接是使用 mysql_connect 打开的时候,执行 mysqli_multi_query 会有警告:Warning: mysqli_multi_query() expects parameter 1 to be mysqli解决方法使用 mysq
当使用的数据库连接是使用 mysql_connect 打开的时候,执行 mysqli_multi_query 会有警告:Warning: mysqli_multi_query() expects parameter 1 to be mysqli
解决方法
使用 mysqli_connect 打开数据库连接
示例代码:
<?php
mysqli_report(MYSQLI_REPORT_ERROR | MYSQLI_REPORT_STRICT);
$link = mysqli_connect("localhost", "my_user", "my_password", "world");
$query = "SELECT CURRENT_USER();";
$query .= "SELECT Name FROM City ORDER BY ID LIMIT 20, 5";
/* 批量执行查询 */
mysqli_multi_query($link, $query);
do {
/* store the result set in PHP */
if ($result = mysqli_store_result($link)) {
while ($row = mysqli_fetch_row($result)) {
printf("%s\n", $row[0]);
}
}
/* print divider */
if (mysqli_more_results($link)) {
printf("-----------------\n");
}else{
break;
}
} while (mysqli_next_result($link));参考:https://www.php.net/manual/zh/mysqli.multi-query.php
本文由 微wx笑 创作,采用 署名-非商业性使用-相同方式共享 4.0 许可协议,转载请附上原文出处链接及本声明。
原文链接:https://www.ivu4e.cn/blog/service/2023-01-06/1644.html



