Why does mysql give me this error
"Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in /customers/johnex.se/johnex.se/httpd.www/paging.php on line 77"
I made a paging class, and this is what retrieves the data from the database:
//============================//
// Database Retrieval //
//============================//
$offset = intval($_REQUEST['offset']);
if (! $offset) { $offset = 1; }
$per_page = 5;
$conn = mysql_connect('$host', '$user', '$pass') or die(mysql_error());
mysql_select_db('$db',$conn) or die(mysql_error());
$count_command = 'SELECT * FROM zodiac';
$count = mysql_query($count_command, $conn);
$total = mysql_num_rows($count);
// LIMIT $offset - 1,$per_page
$ar = mysql_query('SELECT * FROM zodiac ORDER BY id LIMIT $offset - 1, $per_page', $conn);
while ($v = mysql_fetch_array($ar)) {
$sign = $v['sign'];
$symbol = $v['symbol'];
$id = $v['id'];
print $sign.', '.$symbol.' ('.$id.')<br/>';
}
$paging->indexedlinks($total,$offset,$per_page);
printf('<br/>(Displaying %d - %d of %d)',$offset,$offset+$k,$total);
?>
what is wrong with the script?
line 77 is:
while ($v = mysql_fetch_array($ar)) {
Here is the working script:
Paging Class