Re: Shopping Cart Sessions - Think this is a simple prolem- hopefully

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



1. Are you 100% sure register_globals is turned on?
2. You session_register your variable before you change it.  Replace
    $ShoppingCart with $_SESSION[ShoppingCart] every time you use it.  This way
    you are modifying the session variable actually in the session, not just
    the one time.

   session_register() copies the named variable into the session space, but
   adding or removing items from that variable does NOT change it in the
   session if you use _register.  If you modify $_SESSION[shoppingcart]
   every time, then you are actually reading/writing to the real session
   variable and don't have to worry about it.

Peter

On Thu, 14 Nov 2002, Boa Constructor wrote:

> Evening all, I'm pretty stumped with this basic shopping cart I'm trying
> to integrate into my site, if u wanna see what I'm on about visit
> http://www.hostmaster-x.co.uk/Products.php.  On my products script I've
> got the following:
> [...]
> Of course I need a link so that I can buy a product, so I've got the following in a loop:
> echo "<a href=$PHP_SELF?buy=$i>Buy</a><BR>";
>
> The link works fine for each product, the problem is that the ID of the
> product doesn't seem to be stored in the session and I get a whole pile
> of mysql errors which don't appear in the same page when products are
> displayed.  The errors highlight the following code:
>
> while($ProductDetails = mysql_fetch_array($Q))
> {
> $ProductID = $ProductDetails["ID"];
> $ProductName = $ProductDetails["ProductName"];
> $SellingPrice = $ProductDetails["SellingPrice"];
> $ProductPicture = $ProductDetails["PictureOfProduct"];
> $AmountInStock = $ProductDetails["AmountInStock"];
> $Description = $ProductDetails["ProductDescription"];
> $PictureOfProduct = $ProductDetails["PictureOfProduct"];
> }
> if(mysql_num_rows($Q) > 0)
>
> Anyone got any ideas? I'm a bit lost as to why this doesn't work.
>
> G :)

---------------------------------------------------------------------------
Peter Beckman            Systems Engineer, Fairfax Cable Access Corporation
beckman@purplecow.com                             http://www.purplecow.com/
---------------------------------------------------------------------------



-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [PHP Users]     [Postgresql Discussion]     [Kernel Newbies]     [Postgresql]     [Yosemite News]

  Powered by Linux