PHP错误:mysqli_free_result($ result);

时间:2012-12-13 07:50:41

标签: php mysql

此错误的解决方案是什么:

  

警告:mysqli_free_result()期望参数1为mysqli_result,   

中给出的null
$result = HSDB::getInstance()->selectlast_classification(); 
#while ($row = mysqli_fetch_array($result)); { 
while ($row_cnt = $result->num); { 
  $fkclassification = $row["pkid"]; 
} 
mysqli_free_result($result);

3 个答案:

答案 0 :(得分:1)

错误解释。您必须为函数mysqli_free_result()

提供MySQLi资源句柄

答案 1 :(得分:0)

请参阅mysqli_free_result

  

<强>结果
  仅限过程样式:mysqli_query(),mysqli_store_result()或mysqli_use_result()返回的结果集标识符。

mysqli_query的返回值因错误而为假时,可能会发生此错误。您可以通过检查所有mysqli_*()次调用的返回值来避免这种情况。例如

$result = mysqli_query($mysqli, 'select * from mytable) or die(mysqli_error($mysqli));

$result = mysqli_query($mysqli, 'select * from mytable);
if ($result === false) {
    // error handling
}

答案 2 :(得分:-2)

如果你有

$myConnection = mysqli_connect($db_host, $db_username, $db_pass, $db_name) 
or die ("could    not connect to mysql");  
$sql = "SELECT blabla from blalala where bla=1";
$query = mysqli_query($myConnection,$sql) or die (mysqli_error($myConnection));
while ($row=mysqli_fetch_array($query)){
  //do something 
}

比你能做的更多:

mysqli_free_result($query);