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 trial![](https://ecs-static.teamtreehouse.com/assets/views/marketing/shared/community-banner-white-47072046c51352fe6a69f5e691ff5700b28bb11d45197d7bdf066d9ea3f72d0c.webp)
![suyash patankar](https://secure.gravatar.com/avatar/8b726321ab42249e4a74df8455ca4fa3?s=96&d=https%3A%2F%2Fecs-static.teamtreehouse.com%2Fassets%2Fcontent%2Fdefault_avatar-445fbbabfc8dc9188fb5967fe43322ee0c3e0dd1e10f378bf8343784af5a13eb.webp&r=pg)
suyash patankar
2,310 PointsWhat is wrong? I am getting error 'you have not output first course'
Please let me know what is wrong in it, I have written code as per video.
<?php
/*
{
"name": "Username",
"profile_name": "profile_username",
"profile_url": "http://myapi.net/profile_username"
"courses": [
{ "name": "WordPress Plugin Development" },
{ "name": "WordPress Theme Development" },
{ "name": "Introduction to PHP" }
]
}
*/
?>
<ul>
<?php for( $i = 0; $i < count($my_plugin_profile->courses); $i++ ): ?>
<? echo $my_plugin_profile->{'courses'}[$i]->{'name'}; ?>
<?php endfor; ?>
</ul>
1 Answer
![Greg Kaleka](https://secure.gravatar.com/avatar/54c2cac346df05d7b70cc0a6825c1cba?s=96&d=https%3A%2F%2Fecs-static.teamtreehouse.com%2Fassets%2Fcontent%2Fdefault_avatar-445fbbabfc8dc9188fb5967fe43322ee0c3e0dd1e10f378bf8343784af5a13eb.webp&r=pg)
Greg Kaleka
39,021 PointsHi Suyash,
There are two problems with your answer. One of them is a PHP problem, the other is an HTML problem.
- You need to open your php block with
<?php
, not just<?
- You're just spitting out the names one after the other. You need to wrap each course name in
<li></li>
tags
<?php
/*
{
"name": "Username",
"profile_name": "profile_username",
"profile_url": "http://myapi.net/profile_username"
"courses": [
{ "name": "WordPress Plugin Development" },
{ "name": "WordPress Theme Development" },
{ "name": "Introduction to PHP" }
]
}
*/
?>
<ul>
<?php for( $i = 0; $i < count($my_plugin_profile->courses); $i++ ): ?>
<li>
<?php echo $my_plugin_profile->{'courses'}[$i]->{'name'}; ?>
</li>
<?php endfor; ?>
</ul>
![suyash patankar](https://secure.gravatar.com/avatar/8b726321ab42249e4a74df8455ca4fa3?s=60&d=https%3A%2F%2Fecs-static.teamtreehouse.com%2Fassets%2Fcontent%2Fdefault_avatar-445fbbabfc8dc9188fb5967fe43322ee0c3e0dd1e10f378bf8343784af5a13eb.webp&r=pg)
suyash patankar
2,310 PointsThank you very much Greg
velochicdunord
4,816 Pointsvelochicdunord
4,816 PointsFWIW, I'm having trouble with the same exercise.