Warning: mysqli_fetch_array() expects parameter 1 to be mysqli_result, object given in

你离开我真会死。 提交于 2020-05-14 04:02:11

问题


I'm got a little bit problem when I try to run this code.

My problem is on line 32:


回答1:


Warning: mysqli_fetch_array() expects parameter 1 to be mysqli_result, object given in

mysqli_fetch_array's 1st parameter must be a result of a query. what you are doing is you are you are passing the connection(which doesnt makes sense) and the query command itself.

read the doc here: http://php.net/manual/en/mysqli-result.fetch-array.php

to fix this, execute the query first, then store the result to a variable then later fetch that variable.

$sql = "select * from privinsi";
$result = mysqli_query($connection,$sql);
while($r = mysqli_fetch_array($result)
{
    /// your code here
}



回答2:


You write sql query but didn't execute.

$sql = "select * from privinsi";
$results = myqli_query($connection,$sql);
while($r = mysqli_fetch_array($results){
   //enter your code here
}


来源:https://stackoverflow.com/questions/40304560/warning-mysqli-fetch-array-expects-parameter-1-to-be-mysqli-result-object-gi

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!