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 trialAmber O'Rear
7,791 PointsWorking on displaying specific categories for each page and all the sudden I am getting this error when refreshing
"Books", "Movies" and "Music" pages...
Parse error: syntax error, unexpected '$pageTitle' (T_VARIABLE) in /home/treehouse/workspace/catalog.php on line 5
<?php include("inc/data.php"); include("inc/functions.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 catalog page">
<div class="wrapper">
<h1><?php echo $pageTitle; ?></h1>
<ul class="items">
<?php
$categories = array_category($catalog,$section);
foreach ($categories as $id) {
echo get_item_html($id,$catalog[$id]);
}
?>
</ul>
</div>
</div>
2 Answers
Benjamin Payne
8,142 PointsHey Amber,
Right after include("inc/functions.php")
you are missing a semi-colon. Just some friendly advice...try to keep individual statements on their own line. This will help you spot syntax errors like this. If you can, try and configure your editor to warn you when you are breaking a specific coding style like PSR1/2. This will help as well.
Thanks,
Ben
Amber O'Rear
7,791 PointsOh wow, thank you, I can't believe I missed that! They are on separate lines in the workspace but when I copied it over it combined them. Haven't figured out how to get the actual workspace screen over to "get help". How do you configure the editor?
Benjamin Payne
8,142 PointsGotcha...I try and use a separate editor whenever possible. Workspaces is nice but its functionallity is limited and i don't think it does syntax and error highlighting.