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);
?>
解决方案 »
- 怎样传递数值echo '<a href="view_post.php?post_id=$result_row["post_id"]>';
- 栏目页网页左下角错误提示不能给函数返回值赋值
- 花了一点时间写了一个 PR 查询程序,php + jquery,大家帮忙测试下,散分!
- 怎样和数据库进行实时交互!
- linux下的定时任务怎么做?在线给分
- 关于复选框的值传入数据库问题!
- http://www.a.com/abc.php/b.html 这是什么技术?怎么用?
- 通过php将excel导到mysql后,页面显示没有找到网页?如何解决?
- 问一下关于文件操作的几个问题(fopen,fseek,fputs,fgets,fgetc,feof,rewind,ftell)
- 求助那位大侠用过mail()函数。
- PHP套接字链接问题
- PhpStorm连接linux咋超时啊?
这样提示什么错误
啊,太粗心了···数据库是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 ","");