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 trialRobbie Thomas
31,093 PointsBuilding a Media Library in PHP issue
I have completed the above titled lesson here on Treehouse under Build a Basic PHP Website. However, at the last video, I swear I followed along just right with the header.php file. However, I'm getting a error on line 16.
Here is the code for header.php:
<html>
<head>
<title><?php echo $pageTitle; ?></title>
<link rel="stylesheet" href="css/style.css" type="text/css">
</head>
<body>
<div class="header">
<div class="wrapper">
<h1 class="branding-title"><a href="./">Personal Media Library</a></h1>
<ul class="nav">
<li class="books<?php if ($section == "books" { echo " on"; } ?>"><a href="catalog.php?cat=books">Books</a></li>
<li class="movies<?php if ($section == "movies" { echo " on"; } ?>"><a href="catalog.php?cat=movies">Movies</a></li>
<li class="music<?php if ($section == "music" { echo " on"; } ?>"><a href="catalog.php?cat=music">Music</a></li>
<li class="suggest<?php if ($section == "suggest" { echo " on"; } ?>"><a href="suggest.php">Suggest</a></li>
</ul>
</div>
</div>
<div id="content">
Sorry if I don't have the proper backing for the code, it doesn't seem to allow me to do that here for some reason. Any help on why I'm getting the error will be helpful. Thanks!
1 Answer
Kent ร svang
18,823 Points<ul class="nav">
<li class="books<?php if ($section == "books" ) /* <- closing parenthesis */ { echo " on"; } ?>"><a href="catalog.php?cat=books">Books</a></li>
<li class="movies<?php if ($section == "movies") /* <- closing parenthesis */{ echo " on"; } ?>"><a href="catalog.php?cat=movies">Movies</a></li>
<li class="music<?php if ($section == "music") /* <- closing parenthesis */ { echo " on"; } ?>"><a href="catalog.php?cat=music">Music</a></li>
<li class="suggest<?php if ($section == "suggest")/* <- closing parenthesis */ { echo " on"; } ?>"><a href="suggest.php">Suggest</a></li>
</ul>
You have forgotten a closing parenthesis on your if-statements. Should work fine after you include them =)
Jason Anello
Courses Plus Student 94,610 PointsJason Anello
Courses Plus Student 94,610 Pointschanged from comment to answer
Robbie Thomas
31,093 PointsRobbie Thomas
31,093 PointsThanks, boy do I feel like a dummy!