我有以下代码。mysql_num_rows()不是一个有效的资源 - mysql_error()什么也没有显示
include("DBHeader.inc.php");
include("libs/ps_pagination.php");
$sql = "SELECT * FROM Products P, Manufacturers M WHERE M.sManufacturerCode='$LC' AND M.iManufacturerID=P.iManufacturerID";
$rs = mysql_query($sql);
echo $sql;
$pager = new PS_Pagination($conn, $sql, 3, 4, null);
$rs = $pager->paginate();
$num = mysql_num_rows($rs) or die('Database Error: ' . mysql_error());
if ($num >= 1) {
echo "<table border='0' id='tbProd' class='tablesorter' style='width:520px;'>
<thead>
<tr>
<th>Product Code</th>
<th>Product Name</th>
<th> </th>
</tr>
</thead>
<tbody>";
//Looping through the retrieved records
while($row = mysql_fetch_array($rs))
{
echo "<tr class='prodRow'>";
echo "<td>" . $row['sProductCode'] . "</td>";
echo "<td>" . $row['sProductName'] . "</td>";
echo "<td><a href='ProdEdit.php?=" . $row['sProductCode'] . "'><img src='images/manage.gif' alt='Edit " . $row['sProductName'] . "' /></a></td>";
echo "</tr>";
}
echo "</tbody></table>";
}
else {
//if no records found
echo "No records found!";
}
,而不是它给我从表中数据,它吐出来在屏幕上:
Warning: mysql_num_rows(): supplied argument is not a valid MySQL result resource in /home/nyksys/www/regserver2/search_results.php on line 37
mysql_error()
实际上返回什么都没有,所以我以很迷茫什么错误是。 echo'd时的SQL:
SELECT * FROM Products P, Manufacturers M WHERE M.sManufacturerCode='216E3ACAC673DE0260083B5FF809B102B3EC' AND M.iManufacturerID=P.iManufacturerID
我在这里感到莫名其妙!我在这里忽略简单的东西吗?
我已经仔细检查了我的数据库信息,我确定这不是问题。
编辑 - 我正在按照教程Paginating Your Data with AJAX and Awesome PHP Pagination Class。
我们不知道你的'$ rs'变量包含... – Neal