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 trialBenjamin Payne
7,167 PointsCan't figure out what's wrong with my code in this challenge
The Preview button doesn't work, and I have come back to this challenge a few different times. I feel like my code is right - cannot figure out what is wrong.
<?php
$recommendations = array();
?><html>
<body>
<h1>Flavor Recommendations</h1>
<?php if (!empty($recommendations) {
echo "<ul>";
foreach($recommendations as $flavor) {
echo "<li>" . $flavor . "</li>";
}
echo "</ul>";
} ?>
</body>
</html>
5 Answers
Mario Blokland
19,750 PointsHi Benjamin Payne,
it seems like you forgot to close the if statement properly because it is missing the closing parenthese. It is in the line which checks if $recommendations is empty.
Got it?
Benjamin Payne
7,167 PointsI put it down before the </body> tag so that it encloses the whole thing. Is that wrong?
Benjamin Payne
7,167 PointsGood grief. Thank you. I always try to check that stuff first, but I still missed it.
Mario Blokland
19,750 PointsI know that feeling when you think you have made everything correct and the mistake shouldn't be on part of your side and you struggle and in the end it is just such a small typing error :-)
thomascawthorn
22,986 PointsYou wont believe the number of times this particular syntax error got me when I started out - and still now!!
thomascawthorn
22,986 Pointsthomascawthorn
22,986 PointsBenjamin Payne you have:
and you need
<?php if (!empty($recommendations)) {
look closely at the two closing parenthese. You need one to close the if condition and another to close the empty function.