警告错误mysqli_fetch_array()/mysqli_fetch_assoc()/mysqli_fetch_r
|
今天在编写php mysql数据库编程的时候,遇到了mysql_fetch_row() expects parameter 1 to be resource,boolean given 的错误。后来仔细检查了一下代码,问题得到解决。将解决方法记录下来给大家分享一下。 我的代码如下: //error message (not found message) $XX = "No Record Found"; mysql_select_db("india3arts") or die( "Unable to select database"); ?> //error message (not found message) $XX = "No Record Found"; $result1 = msql_query ("select * FROM items where ".$metode." like '%".$search."%' limit 0,1095 "); while ($row = mysql_fetch_array($result1)) { $variable1=$row["itemDesc"]; $variable2=$row["itemName"]; $variable3=$row["itemPrice"]; print ("this is for $row["itemDesc"];,and this print the variable2 end so on..."); } //below this is the function for no record!! if (!$variable1) { print ("$XX"); } //end ?> 上面代码出现mysql_fetch_row() expects parameter 1 to be resource,boolean given 的错误,原因是mysql_query这里出错,传入的sql字符串无法正确执行,导致$result1为false。 总结 当你看到这个的警告的时候 肯定是因为你的SQL语句没有执行成功,仔细检查一下数据库配置然后打印出所执行的SQL语句,很可能是不小心打错的小错误。 (编辑:安卓应用网) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |
