c_shelswell Posted February 18, 2007 Share Posted February 18, 2007 Got this strange problem in a shopping cart i'm building. This is working absolutely fine on my dev pc (php5) but not working online also php5. my code is $new = $_GET['media_id']; if ($new) { if (!isset($_SESSION['cart'])) { $_SESSION['cart'] = array(); $_SESSION['items'] = 0; $_SESSION['total_price'] = '0.00'; } if (isset($_SESSION['cart'][$new])) { $_SESSION['cart'][$new] += 1; } else $_SESSION['cart'][$new] = 1; $_SESSION['total_price'] = calculate_price($_SESSION['cart']); $_SESSION['items'] = calculate_items($_SESSION['cart']); } which should basically add a new item to the cart. On ie6 the it doesn't seem to add anything at all on firefox it works the first time you add an item then the second time you get this error: Fatal error: Cannot use assign-op operators with overloaded objects nor string offsets in /home/chriss/public_html/cart_add.php on line 16 referring to this line "$_SESSION['cart'][$new] += 1;" Like i say the whole cart is working fine on my box just not online what's even stranger is how ie6 and firefox would react differently to a php script any ideas? Cheers meant to say if i do a print_r session online the 'cart' variable is empty and not even set as an array Link to comment https://forums.phpfreaks.com/topic/39047-solved-strange-session-problem/ Share on other sites More sharing options...
c_shelswell Posted February 19, 2007 Author Share Posted February 19, 2007 Turns out this was a problem with globals being turned on on my server. I had another variable called $cart which was causing things to mess up. Link to comment https://forums.phpfreaks.com/topic/39047-solved-strange-session-problem/#findComment-188446 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.