Seems to me that the problem might be in the logic (correct me if I'm wrong
- likely - but...)
In these lines :
foreach ($cart as $id => $qty)
if ($$id == "0")
You unset $cart[$id] if $$id==0. Now, if you are using numeric array
indexes, then for example $id might be '12' (number or string, it don't
matter). So what you're asking of php is to get $$id, that works out as $12
, which I guess is not a variable name.
Not being a variable it will return false (or zero) and so $$id=="0" will
be true, your if statement executes and unsets the value for $cart[$id],
which *is* a valid variable name. Could you replace $$id==0 with
isset($$id) and see if you get the same results?
At 20:57 07/02/2002 +0000, you wrote:
>From: Robert Weeks [mailto:[EMAIL PROTECTED]]
>Sent: Thursday, February 07, 2002 10:41 AM
>Subject: Re: [PHP-DB] Viewing Session Varibles
>This is driving me nuts. I'm sure its something simple but I can't seem to
>find the glitch.
>I'm trying to make a simple shopping cart using Session varibles to store
>the item => quantity pairs, then I loop thru the cart and query the db to
>get the item details, etc.. Most of it works fine but whenever I add a new
>item to the cart I lose the $qty value for the other items.
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php