RE: [PHP] Invalid MySQL result resource
| From: | Dan Harrington | Date: | Thu, 13 Sep 2001 04:45:37 +0000 |
| Subject: | RE: [PHP] Invalid MySQL result resource | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-67123@lists.php.net to get a copy of this message | ||
> -----Original Message-----
> From: speedboy [mailto:speedboy@nomicrosoft.org]
> Sent: Wednesday, September 12, 2001 10:27 PM
> To: php-general@lists.php.net
> Subject: Re: [PHP] Invalid MySQL result resource
>
>
> > "Supplied argument is not a valid MySQL result resource in ..... on line 52"
> >
> > Line 52 is the line where I fetch the row from the second query.
>
> Don't keep doing a mysql_connect on each loop.
>
....thats whats weird about this,
I'm not.
Here's what's going on.
========================================================
$connection = mysql_connect($server, $user, $pass);
mysql_select_db($db);
$query = "select * from shoppingcart where PHPSESSID = '$PHPSESSID'";
$result = mysql_query($query,$connection);
$numrows = mysql_num_rows($result);
$count = 0;
while ($count < $numrows){
$cartitem = mysql_fetch_array($result);
$productquery = "select * from products where productid =
'$cartitem[productid]'";
$productresult = mysql_query($productquery);
$productinfo = mysql_fetch_array($productresult); //THIS line produces the error
$count++;
}
mysql_close($connection);
========================================================
I don't get it. I must be blind or something because I just don't
see whats causing this.
Thanks again,
Dan