On Thu, 13 Sep 2001 14:15, Dan Harrington wrote:
> > -----Original Message-----
> > From: speedboy [mailto:[EMAIL PROTECTED]]
> > Sent: Wednesday, September 12, 2001 10:27 PM
> > To: [EMAIL PROTECTED]
> > 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);

Ah. Should that be $cartitem[$productid]  ??? And perhaps better written 
as 

$productquery = "select * from products where productid =
 '" . $cartitem[productid] . "'";

to be sure that the array element is dereferenced properly.

> $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

-- 
David Robley      Techno-JoaT, Web Maintainer, Mail List Admin, etc
CENTRE FOR INJURY STUDIES      Flinders University, SOUTH AUSTRALIA  

   Half the lies they tell me aren't true. --Yogi Berra

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]

Reply via email to