Heim >Backend-Entwicklung >PHP-Tutorial > mysql_fetch_array() expects parameter 1 to be resource, boolean given in D:何解?解决办法
mysql_fetch_array() expects parameter 1 to be resource, boolean given in D:何解?
mysql_fetch_array() expects parameter 1 to be resource, boolean given in D:\xampp\htdocs\4.php on line 12
请问是什么错误?如何改正?谢谢大家啊~
代码如下:
$con = mysql_connect("localhost","root ","");
//通过服务器locahost建立连接,用户名为root,无密码
if (!$con)
{
die('Could not connect: ' . mysql_error());
}//如果不成功,显示错误
mysql_select_db("crms", $con);//选择数据库
$result = mysql_query("SELECT * FROM Cno");//查找
while($row = mysql_fetch_array($result))//打印
{
echo $row['Cno'] . " " . $row['Cno'];
echo "
";
}
mysql_close($con);
?>
------解决方案--------------------