Welcome to the Treehouse Community

The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.

PHP Build a Basic PHP Website (2018) Building a Media Library in PHP Adding Active States to the Navigation

Parse 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
PLUS
Sharina Jones
Courses Plus Student 18,771 Points

It 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"
  }

Oh my god! I can't believe I missed such a beginner mistake! Now I feel very dumb. Thanks so much for pointing that out!