PDA

View Full Version : Same query in different module, one works, one show warning


dawnP
02-02-2006, 07:29 PM
Hi all, I use the following code to in two different module.

$queryroot2=mysql_query("select name,id,parent_id from categories where parent_id=$catID and status<>0 order by sort_order");
while($first_result2 = mysql_fetch_array($queryroot2))
{
echo "$first_result2[id],$first_result2[parent_id],$first_result2[name]\n";
}
mysql_free_result($queryroot2);

1. inside a javascript, no warning (at least seemingly)
2. inside a php module, the following shows:

Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in /usr/local/home/w1000457/site/mainx.php on line 303

Warning: mysql_free_result(): supplied argument is not a valid MySQL result resource in /usr/local/home/w1000457/site/mainx.php on line 307

The line numbers are referring to the mysql_fetch and mysql_free statements respectively. Any hint?

dawnP
02-02-2006, 11:15 PM
I have got the answer. It happens when I do not assign the value for the $catID. Thank you anyway.