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 trialKat Stacy
41,658 PointsParse error: syntax error, unexpected '}' in /home/treehouse/workspace/catalog.php on line 9
I do not know how to fix this or why it is saying I have an unexpected '}' on line 9. This is a conditional statement there should be curly braces there. I am so confused about why my code won't run.
<?php
$pageTitle = "Full Catalog";
$section = null;
if (isset($_GET["cat"])) {
if ($_GET["cat"] == "books") {
$pageTitle = "Books";
$section = "books"
} else if ($_GET["cat"] == "movies") {
$pageTitle = "Movies";
$section = "movies";
} else if ($_GET["cat"] == "music") {
$pageTitle = "Music";
$section = "music";
}
}
include("inc/header.php"); ?>
<div class="section page">
<h1><?php echo $pageTitle; ?></h1>
</div>
<?php include("inc/footer.php"); ?>
1 Answer
Sharina Jones
Courses Plus Student 18,771 PointsIt looks like you've missed a semi-colon. There is no semi-colon after books in this section of code:
<?php
if ($_GET["cat"] == "books") {
$pageTitle = "Books";
$section = "books"
}
Kat Stacy
41,658 PointsKat Stacy
41,658 PointsOh my god! I can't believe I missed such a beginner mistake! Now I feel very dumb. Thanks so much for pointing that out!
Sharina Jones
Courses Plus Student 18,771 PointsSharina Jones
Courses Plus Student 18,771 PointsKathryn Stacy I'm glad I could help :)