RE: [PHP]Not a valid RESOURCE??..help please!
| From: | Jason Murray | Date: | Wed, 17 Oct 2001 00:13:28 +0000 |
| Subject: | RE: [PHP]Not a valid RESOURCE??..help please! | ||
| Groups: | php.general | ||
| Request: | Send a blank email to php-general+get-71278@lists.php.net to get a copy of this message | ||
> include("/home/fplg/db/db_config.php");
> $conn = db_connect("fplg");
> $pic_query = "SELECT picid,path,width,height FROM pics WHERE
> id = '".$id."'";
> echo $pic_query;
> $pic_result = mysql_query($pic_query,$conn);
> echo "pic result complete";
> while($pic_data = mysql_fetch_array($pic_result)) {
> ?>
>
> can someone give me any hint as to what may be wrong with
> this...it's telling me that the line inside the while loop
> condition is not a valid resources(note: i tried this without
> the loop with the same problem)...what's wrong??
You should do some error checking on your MySQL.
"Not a valid resource" means there's no MySQL result set when you
are trying to use mysql_fetch_array. A better way to do it:
<?
if ($pic_result = mysql_query($pic_query,$conn))
{
echo "pic result successful";
while($pic_data = mysql_fetch_array($pic_result))
{
...
}
}
else
{
echo mysql_error();
}
?>
Jason