Freedom-n-Democrazy Posted October 4, 2011 Share Posted October 4, 2011 I am following a tutorial on how to make a simple PHP shopping cart at: http://v3.thewatchmakerproject.com/journal/276/ I have discovered a problem with the code where a } is not closed. $cart = $_SESSION['cart']; if ($cart) { $items = explode(',',$cart); $contents = array(); foreach ($items as $item) { $contents[$item] = (isset($contents[$item])) ? $contents[$item] + 1 : 1; } Should the } go on the end of the code or is it suppose to go else where within it? Quote Link to comment https://forums.phpfreaks.com/topic/248384-found-a-bug-in-a-tutorial-and-hoping-someone-can-help-me-fix-it/ Share on other sites More sharing options...
wigpip Posted October 4, 2011 Share Posted October 4, 2011 for your shopping cart like so just one more to end the if cart statement do everything within $cart = $_SESSION['cart']; if ($cart) { $items = explode(',',$cart); $contents = array(); foreach ($items as $item) { $contents[$item] = (isset($contents[$item])) ? $contents[$item] + 1 : 1; } } Quote Link to comment https://forums.phpfreaks.com/topic/248384-found-a-bug-in-a-tutorial-and-hoping-someone-can-help-me-fix-it/#findComment-1275515 Share on other sites More sharing options...
Freedom-n-Democrazy Posted October 4, 2011 Author Share Posted October 4, 2011 Thats dude! Quote Link to comment https://forums.phpfreaks.com/topic/248384-found-a-bug-in-a-tutorial-and-hoping-someone-can-help-me-fix-it/#findComment-1275518 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.