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>
哪错了?求大神帮助。

解决方案 »

  1.   

    $query="select * from chatroom where times>'$times'"; 去掉这行中的单引号试试
      

  2.   

    mysql_select_db() expects parameter 2 to be resource, boolean given
    mysql_select_db() 的第二个参数应该是资源,现在却是逻辑值表示 $link=mysql_connect("localhost","root","123456");
    数据库连接失败,但为什么没报错呢?
      

  3.   

    链接失败,返回false,所以$link为false,不是resouce类型
      

  4.   

    数据库连接没有成功创建。
    $link=mysql_connect("localhost","root","123456") or die(mysql_error());
    加上错误输出看看是什么问题。