Jump to content

Found a bug in a tutorial and hoping someone can help me fix it


Recommended Posts

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?

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;
}
}

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.