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? 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; } } 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! 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
Archived
This topic is now archived and is closed to further replies.