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

Kat Stacy
Kat Stacy
39,242 Points

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
PRO
Sharina Jones
Pro 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"
  }
Kat Stacy
Kat Stacy
39,242 Points

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!