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);
?>

解决方案 »

  1.   

    if (!mysql_select_db("crms", $con)) die(mysql_error()); //要么是数据库不存在,要么就是下一行查询中的Cno表不存在
      

  2.   

    $result = mysql_query("SELECT * FROM Cno") or die(mysql_error());
    这样提示什么错误
      

  3.   


    啊,太粗心了···数据库是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);
    ?>
      

  4.   

    如楼上所说,然后:$sql="SELECT * FROM Cno";
    $result = mysql_query($sql,$con);//查找
    if(!$result)
        die("SQL: {$sql}<br>Error:".mysql_error());
      

  5.   

    因为mysql_query失败返回false了。
      

  6.   


    mysql_query() or die (mysql_error());
    在这里如果sql_query出错就会停下来,这样就不会等到mysql_fetch_array再报错误讯息了
      

  7.   

    Access denied for user ''@'localhost' to database 'crms'这样的错误该怎么改呢?
      

  8.   

    提示在服务器名"localhost"下,用 用户名""无法访问数据库"crms"
    在mysql数据库中的user表中查看host字段值为“localhost”的数据,确认其user,password字段值均非空。然后:$con = mysql_connect("localhost","root ","");