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 trialRobert Engelbert
7,229 Pointskeep getting an error
I keep getting an error that says Parse error: syntax error, unexpected ';' in /home/treehouse/workspace/inc/functions.php on line 16
<?php
function get_item_html($id,$item) {
$output = "<li><a href='#'><img src='"
. $item["img"] . "' alt='"
. $item["title"] . "'/>"
. "<p>View Detials</p>"
. "</a></li>";
return $output;
}
function array_category($catalog,$category) {
$output = array();
foreach ($catalog as $id => $item) {
if ($category == null OR (strtolower($category) == strtolower($item["category"])){
$sort = $item["title"];
$sort = ltrim($sort,"The ");
$sort = ltrim($sort,"A ");
$sort = ltrim($sort,"An ");
$output[$id] = $sort;
}
}
asort($output);
return array_keys($output);
}
here's line 16
$sort = $item["title"];
I've went over and over this and I can't find anything wrong, any help would be appreciated.
1 Answer
Jennifer Nordell
Treehouse TeacherHey there! You're doing great! Would it be encouraging to know that it's just a runaway parenthesis? It's a good idea when looking at an error to also look at the lines above it. Often that's what is causing the problem. In this case, it's the line immediately above.
It should look like this:
if ($category == null OR strtolower($category) == strtolower($item["category"])) /* note the removal of the open parenthesis between the OR and the strtolower */
Happy coding!
Robert Engelbert
7,229 PointsRobert Engelbert
7,229 PointsJennifer you are awesome! I spent a lot of time looking at that code. Thank you
Jennifer Nordell
Treehouse TeacherJennifer Nordell
Treehouse TeacherRobert Engelbert You're quite welcome!