Welcome to the Treehouse Community
Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.
Start your free trialNazan Gökbulut
Courses Plus Student 3,910 PointsParse error: syntax error, unexpected '}' in C:\xampp\htdocs\inc\products.php on line 78
I have a problem on line 78 but in this line i don't have any curly bracket. I've tried to copy the whole file from the downloads but it throws the same error. i hope you can help me. The error-line is ' "name" => "Logo Shirt, Teal", ' of product [107]
<?php
function get_list_view_html($product) {
$output = "";
$output = $output . "<li>";
$output = $output . '<a href="' . BASE_URL . 'shirts/' . $product["sku"] . '/">';
$output = $output . '<img src="' . BASE_URL . $product["img"] . '" alt="' . $product["name"] . '">';
$output = $output . "<p>View Details</p>";
$output = $output . "</a>";
$output = $output . "</li>";
return $output;
}
function get_products_recent() {
$recent = array();
$all = get_products_all();
$total_products = count($all);
$position = 0;
foreach($all as $product) {
$position = $position + 1;
if ($total_products - $position < 4) {
$recent[] = $product;
}
}
return $recent;
}
function get_products_all() {
$products = array();
$products[101] = array(
"name" => "Logo Shirt, Red",
"img" => "img/shirts/shirt-101.jpg",
"price" => 18,
"paypal" => "9P7DLECFD4LKE",
"sizes" => array("Small","Medium","Large","X-Large")
);
$products[102] = array(
"name" => "Mike the Frog Shirt, Black",
"img" => "img/shirts/shirt-102.jpg",
"price" => 20,
"paypal" => "SXKPTHN2EES3J",
"sizes" => array("Small","Medium","Large","X-Large")
);
$products[103] = array(
"name" => "Mike the Frog Shirt, Blue",
"img" => "img/shirts/shirt-103.jpg",
"price" => 20,
"paypal" => "7T8LK5WXT5Q9J",
"sizes" => array("Small","Medium","Large","X-Large")
);
$products[104] = array(
"name" => "Logo Shirt, Green",
"img" => "img/shirts/shirt-104.jpg",
"price" => 18,
"paypal" => "YKVL5F87E8PCS",
"sizes" => array("Small","Medium","Large","X-Large")
);
$products[105] = array(
"name" => "Mike the Frog Shirt, Yellow",
"img" => "img/shirts/shirt-105.jpg",
"price" => 25,
"paypal" => "4CLP2SCVYM288",
"sizes" => array("Small","Medium","Large","X-Large")
);
$products[106] = array(
"name" => "Logo Shirt, Gray",
"img" => "img/shirts/shirt-106.jpg",
"price" => 20,
"paypal" => "TNAZ2RGYYJ396",
"sizes" => array("Small","Medium","Large","X-Large")
);
$products[107] = array(
"name" => "Logo Shirt, Teal", //this line is the error line 78
"img" => "img/shirts/shirt-107.jpg",
"price" => 20,
"paypal" => "S5FMPJN6Y2C32",
"sizes" => array("Small","Medium","Large","X-Large")
);
$products[108] = array(
"name" => "Mike the Frog Shirt, Orange",
"img" => "img/shirts/shirt-108.jpg",
"price" => 25,
"paypal" => "JMFK7P7VEHS44",
"sizes" => array("Large","X-Large")
);
foreach ($products as $product_id => $product) {
$products[$product_id]["sku"] = $product_id;
}
return $products;
}
?>
Nazan Gökbulut
Courses Plus Student 3,910 PointsHi chris,
I use Apache 2.4.10 and PHP 5.6.3 . I saved it and refreshed it several times but it still throws this error.
Chris Shaw
26,676 PointsSorry for the delay, I tested your script again within a clean Windows 8.1 environment using the latest version of Xampp and had no errors appear.
If possible could you please ZIP up your entire project and upload it to something like Dropbox as I can't find anything wrong with the above code.
Nazan Gökbulut
Courses Plus Student 3,910 PointsI've refreshed it a while ago and it worked! although nothing has changed..?!
Chris Shaw
26,676 PointsChris Shaw
26,676 PointsHi Nazan,
I ran your code on my local server and it worked fine, could you please explain the setup you have, e.g. version of Apache/PHP 5.x etc.