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 trialsuyash patankar
2,310 PointsSyntax error - books list not displayed
The code as shown in video
<ul class="items">
<?php
foreach($catalog as $item){
echo "<li><a href='#'><img src='"
. $item["img"] . "' alt='"
. item["title"] . "' />"
. "<p>View details</p>"
. "</a></li>";
}
?>
</ul>
is giving a syntax error Parse error: syntax error, unexpected '[', expecting ',' or ';' in /home/treehouse/workspace/catalog.php on line 40
line 40 is . item["title"] . "' />"
Cena Mayo
55,236 Pointsedited for syntax highlighting. :)
4 Answers
Cena Mayo
55,236 PointsSadly no -- my first (uninformed) thought is that you're missing the '$' on the second item['title'], but I really don't know enough PHP to have anything constructive to say. :)
suyash patankar
2,310 PointsThank you @Cena Mayo
any solution for error removal?
suyash patankar
2,310 Pointsyes, I think that is the issue, thank you so much, I am also new to php
suyash patankar
2,310 PointsIt worked, you can close this discussion, thank you very much for your help @Cena Mayo
suyash patankar
2,310 Pointssuyash patankar
2,310 Pointscode is not displayed properly here, but please help with foreach loop part