Warning: mysql_select_db() expects parameter 2 to be resource, boolean given in D:\wamp\www\get.php on line 9
Warning: mysql_query() expects parameter 2 to be resource, boolean given in D:\wamp\www\get.php on line 11怎么解决?
代码是这样的!
<?php
session_start();
$_SESSION['times'] = null;
if(!isset($times))
{
$times="0";
}
$link=mysql_connect("localhost","root","123456");
mysql_select_db("chatRoom",$link);
$query="select * from chatroom where times>'$times'";
$result=mysql_query($query,$link);
$megs=array();
echo "<script language='JavaScript'>";
while ($row=mysql_fetch_array($result))
{
if($row["times"] >= $times) {
$time = $row["times"];
}
echo "top.chatUserName[top.lines.length]=".$row['chatUser']."';\n";
echo "top.showTime[top.lines.length]=".$row['times']."';\n";
echo "top.lines[top.lines.length]=".$row['msg']."';\n";
echo "document.write(top.lines.length);";
}
echo"top.list.location.reload();";
echo "</script>";
?>
<html>
<head>
</head>
<body onLoad="windows.setInterval('location.reload()'4000);">
<!--每4秒刷新一次-->
<h1>
<p align=a"center">
聊天室
</p>
</h1>
</body>
</html>
哪错了?求大神帮助。
Warning: mysql_query() expects parameter 2 to be resource, boolean given in D:\wamp\www\get.php on line 11怎么解决?
代码是这样的!
<?php
session_start();
$_SESSION['times'] = null;
if(!isset($times))
{
$times="0";
}
$link=mysql_connect("localhost","root","123456");
mysql_select_db("chatRoom",$link);
$query="select * from chatroom where times>'$times'";
$result=mysql_query($query,$link);
$megs=array();
echo "<script language='JavaScript'>";
while ($row=mysql_fetch_array($result))
{
if($row["times"] >= $times) {
$time = $row["times"];
}
echo "top.chatUserName[top.lines.length]=".$row['chatUser']."';\n";
echo "top.showTime[top.lines.length]=".$row['times']."';\n";
echo "top.lines[top.lines.length]=".$row['msg']."';\n";
echo "document.write(top.lines.length);";
}
echo"top.list.location.reload();";
echo "</script>";
?>
<html>
<head>
</head>
<body onLoad="windows.setInterval('location.reload()'4000);">
<!--每4秒刷新一次-->
<h1>
<p align=a"center">
聊天室
</p>
</h1>
</body>
</html>
哪错了?求大神帮助。
解决方案 »
- PHP在线考试系统如何实现在线倒计时
- 关于mysql一次自动插入2条数据出现的原因,和求解决办法。。
- 求助:关于使用.htaccess文件实现伪静态的问题
- PHP怎么样实现高级搜索?谁有完整的代码 帮忙给个谢谢! 急用!!!
- 本地多端口多站点伪静态如何配置?
- 求助贴: Warning: msg_get_queue(): failed for key 0x610005bd: File exists in
- 如何记忆刚才访问的url????
- 那位高手有session写的购物篮!!!100百相送
- 谁 知道 http 头部 规范
- 我想和大家一起进步!php
- PHP访问MSSQL链接服务器问题
- php怎么实现一个可以增加、编辑记录的弹出窗口?
mysql_select_db() 的第二个参数应该是资源,现在却是逻辑值表示 $link=mysql_connect("localhost","root","123456");
数据库连接失败,但为什么没报错呢?
$link=mysql_connect("localhost","root","123456") or die(mysql_error());
加上错误输出看看是什么问题。