错误警告:mysql_fetch_assoc()期望参数1是资源,布尔值在

时间:2014-09-06 12:15:12

标签: php mysql

我的数据库表没有记录时收到此消息 所以如何解决它。

$sql2 = mysql_query("SELECT ID,NAME from login where TYPE='AdPublish' ORDER BY ID ASC $limit") or mysql_error();

if(!$sql2)
{
    die("invalid query".mysql_error());
}
else
{
    while($data=mysql_fetch_array($sql2))
    {   
        $rv1=mysql_query("select LINK from url where ID='".$data['ID']."' AND STATUS='Pending'") or mysql_error();
        $count1=mysql_num_rows($rv1);
        echo '<a href="cidmatter.php?cid='.$data['ID'].'" target="_blank">';
        echo "<table>";
        echo '<tr><td><h4><b>ID: ' .$data['ID'].'</b></H4></td></tr><br>';
        echo '<br><tr><td><b>Name: ' .$data['NAME'].'</b>('.$count1.')</td></tr></table></a>';
        echo '<hr>';
    }
}

1 个答案:

答案 0 :(得分:0)

使用类似的东西

   $sql2 = mysql_query("SELECT ID,NAME from login where TYPE='AdPublish' ORDER BY ID ASC $limit") or die("Error in query");

    while($data=mysql_fetch_array($sql2)){   
        $rv1=mysql_query("select LINK from url where ID='".$data['ID']."' AND STATUS='Pending'") or die("Error in query");
        $count1=mysql_num_rows($rv1);
        echo '<a href="cidmatter.php?cid='.$data['ID'].'" target="_blank">';
        echo "<table>";
        echo '<tr><td><h4><b>ID: ' .$data['ID'].'</b></H4></td></tr><br>';
        echo '<br><tr><td><b>Name: ' .$data['NAME'].'</b>('.$count1.')</td></tr></table></a>';
        echo '<hr>';

}