Accolade Posted November 5, 2012 Share Posted November 5, 2012 (edited) I am attempting to add a product to my cart using an increment. It works, however, when I add the first of any product, it gives me the following errors: Notice: Undefined index: cart in C:\wamp\www\cart.php on line 36 Notice: Undefined offset: 41 in C:\wamp\www\cart.php on line 36 Once the quantity increases above 1, there are no errors. Unsure what is going on. switch($action) { case "add": $_SESSION['cart'][$product_id]++; break; case "remove": if (isset($_SESSION['cart'][$product_id])) { $_SESSION['cart'][$product_id]--;} if($_SESSION['cart'][$product_id] == 0) unset($_SESSION['cart'][$product_id]); break; } Line 36 is: $_SESSION['cart'][$product_id]++; Edited November 5, 2012 by Accolade Quote Link to comment https://forums.phpfreaks.com/topic/270307-notice-undefined-index-undefined-offset/ Share on other sites More sharing options...
Accolade Posted November 5, 2012 Author Share Posted November 5, 2012 Dont fret, I worked it out! Quote Link to comment https://forums.phpfreaks.com/topic/270307-notice-undefined-index-undefined-offset/#findComment-1390295 Share on other sites More sharing options...
Scott_S Posted November 5, 2012 Share Posted November 5, 2012 tag this as "solved" please Quote Link to comment https://forums.phpfreaks.com/topic/270307-notice-undefined-index-undefined-offset/#findComment-1390309 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.