mysql_fetch_array() expects parameter 1 to be resource, boolean given in D:\xampp\htdocs\4.php on line 12请问是什么错误?如何改正?谢谢大家啊~代码如下:<?php
$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 "<br />";
}mysql_close($con);
?>
$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 "<br />";
}mysql_close($con);
?>
这样提示什么错误
啊,太粗心了···数据库是crms 数据表是classroom 包含Cno、size·····但是改成下面这样还不行啊
<?php
$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 classroom");//查找while($row = mysql_fetch_array($result))//打印
{
echo $row['Cno'] . " " . $row['size'];
echo "<br />";
}mysql_close($con);
?>
$result = mysql_query($sql,$con);//查找
if(!$result)
die("SQL: {$sql}<br>Error:".mysql_error());
mysql_query() or die (mysql_error());
在这里如果sql_query出错就会停下来,这样就不会等到mysql_fetch_array再报错误讯息了
在mysql数据库中的user表中查看host字段值为“localhost”的数据,确认其user,password字段值均非空。然后:$con = mysql_connect("localhost","root ","");