1
<?php
$pagesize=20;
@$p=$_GET['p']?$_GET['p']:1;
$offset = ($p-1)*$pagesize;
$query = "select * from `say` order by id DESC limit $offset,$pagesize";
$res=mysql_query($query);
while ($row=mysql_fetch_array($res)){
$pic_id = $row['id'];
?>
2
$count_result=mysql_query("select count(*) as count from say"); $count_array=mysql_fetch_array($count_result);
它们都显示: Warning: mysql_fetch_array() expects parameter 1 to be resource
其实你可以找个翻译软件把warning翻译出来的: mysql_fetch_array需要接收的是一个资源句柄,而你给了个bool值。
为什么mysql_query会返回bool值呢? 查看文档你就会发现,执行语句失败的情况下,mysql_query会返回false。 所以,你在使用$res的时候先应该判断其是否为false