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.

suyash 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,235 Pointsedited for syntax highlighting. :)
4 Answers

Cena Mayo
55,235 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