刚看的某教程,他那没问题,怎么到我这就有问题include 'page.class.php';$link = mysql_connect('localhost','root','');
mysql_select_db('xsphpdb');
$result = mysql_query("select * from shops");$total = mysql_num_rows($result);
$num = 10;
$page = new Page($total,$num);
$sql = "select * from shops{$page->limit}";
$result = mysql_query($sql);
echo '<table align = "center" border = 1 width = "960">';
echo '<caption><h1>shops</h1></caption>';while($row = mysql_fetch_assoc($result))
{
echo '<tr>';
echo '<td>'.$row["id"].'</td>';
echo '<td>'.$row['name'].'</td>';
echo '<td>'.$row['price'].'</td>';
echo '<td>'.$row['num'].'</td>';
echo '<td>'.$row['desn'].'</td>';
echo '</tr>';
}
echo '<tr><td colspan = "5" align = "right">'.$page->fpage().'</td></tr>';
echo '</table>';
Warning: mysql_fetch_assoc() expects parameter 1 to be resource, boolean given in 

解决方案 »

  1.   

    //前面的查询没成功执行吧.
    $result = mysql_query($sql);
    //改为下面一行,看看是否输出错误,你的sql语句应该是写错了,可能是少了个LIMIT操作符
    if (!$result = mysql_query($sql)) die(mysql_error());
      

  2.   

    $sql = "select * from shops {$page->limit}";
    shops 与 {$page->limit} 之间至少要有一个空格
      

  3.   

    mysql_fetch_assoc 改为mysql_fetch_array试试看