这应该是一个相当直截了当的问题。我收到一个Warning: mysql_num_rows() expects parameter 1 to be resource, boolean
错误,我无法找出正确的语法。使用 mysqlerror 我得到You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '-5, 5'
.
任何帮助都会很棒。该代码是我添加的分页的一部分。
受影响的代码片段
<?php
//Number of items to display per page
$perpage = 5;
if(isset($_GET["page"]))
{
$page = intval($_GET["page"]);
}
else
{
$page = 1;
}
$calc = $perpage * $page;
$start = $calc - $perpage;
$result = mysql_query("select * from products Limit $start, $perpage");
$rows = mysql_num_rows($result);
echo mysql_error();
if($rows)
{
$i = 0;
while($post = mysql_fetch_array($result))
{
?>