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 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: