Page 1 of 1

Database fetching gives warning

Posted: Tue Sep 18, 2007 8:33 am
by kkonline

Code: Select all

$sql = "SELECT * FROM reflections WHERE `trusted` = 1 AND `catid` = 1 ORDER BY `id` ASC LIMIT $from, $max_results";

$result = mysql_query($sql) or die('select died: ' . mysql_error());
echo $sql;
echo $result;
while($row = mysql_fetch_array($sql))
{
... some data
}
To this it gives me $sql,$result followed by the warning as shown

SELECT * FROM reflections WHERE `trusted` = 1 AND `catid` = 1 ORDER BY `id` ASC LIMIT 8, 1

Resource id #6

Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in /home/mysite/public_html/addons/class.upload/pages.php on line 67

Re: Database fetching gives warning

Posted: Tue Sep 18, 2007 9:16 am
by kkonline

Code: Select all

$sql = "SELECT * FROM reflections WHERE `trusted` = 1 AND `catid` = 1 ORDER BY `id` ASC LIMIT $from, $max_results";

$result = mysql_query($sql) or die('select died: ' . mysql_error());
echo $sql;
echo $result;
while($row = mysql_fetch_array($result)){
  echo "inside while loop";
}
Now the output is

SELECT * FROM reflections WHERE `trusted` = 1 AND `catid` = 1 ORDER BY `id` ASC LIMIT 8, 1
Resource id #6

No warnings but still it does not go into the while loop and print "inside while loop"... what could be the reason now? Any problem with the query

Posted: Tue Sep 18, 2007 3:28 pm
by feyd
No records were found to match your query.