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 trial

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!