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 Building a Media Library in PHP Working with _GET Variables

The browser says there is a Parse Error with the code, despite being it exactly as in this video.

The Browser error is this:

Parse error: syntax error, unexpected ';' in /home/treehouse/workspace/catalog.php on line 5

catalog.php code is this:

<?php
$pageTitle = "Full Catalog";

if ($_GET["cat"] == "books" {
  $pageTitle = "Books" ;
} else if ($_GET["cat"] == "movies" {
  $pageTitle = "Movies" ;
} else if ($_GET["cat"] == "music" {
  $pageTitle = "Music" ;
} 

include("inc/header.php"); ?>```

header.php code is adjusted:

```<ul class="nav">
                <li class="books"><a href="catalog.php?cat=books">Books</a></li>
                <li class="movies"><a href="catalog.php?cat=movies">Movies</a></li>
                <li class="music"><a href="catalog.php?cat=music">Music</a></li>
                <li class="suggest"><a href="suggest.php">Suggest</a></li>
            </ul>```

1 Answer

Jennifer Nordell
seal-mask
STAFF
.a{fill-rule:evenodd;}techdegree
Jennifer Nordell
Treehouse Teacher

Hi there, Kylian van der Have! It's not exactly like it is in the video. According to the code you've posted it looks like on each if statement you've forgotten the closing parenthesis:

You have:

if ($_GET["cat"] == "books" {
  $pageTitle = "Books" ;
} else if ($_GET["cat"] == "movies" {
  $pageTitle = "Movies" ;
} else if ($_GET["cat"] == "music" {
  $pageTitle = "Music" ;
} 

But it needs to be:

if ($_GET["cat"] == "books") { // added ) here
  $pageTitle = "Books" ;
} else if ($_GET["cat"] == "movies") { // added ) here
  $pageTitle = "Movies" ;
} else if ($_GET["cat"] == "music") {  // added a ) here
  $pageTitle = "Music" ;
} 

Hope this helps! :sparkles: