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 trialSusitha Herath Mudiyanselage
4,957 PointsI don't know whats wrong in here
Can any one please help i'm stuck.
Stone Preston
42,016 Pointsas well as the specific task you are struggling with
5 Answers
Stone Preston
42,016 Pointsyou need to preserve the space between the title and the parenthesis containing the year like so:
<h1><?php echo $movie["title"]?> (1985)</h1>
this would output The Empire Strikes Back (1985)
notice there is space between the closing php tag and the (1985) whereas you originally had:
<h1> <?php echo $movie["title"]?>(1985)</h1>
which does not have a space between the title and the year, which is why its not letting you pass since it outputs
The Empire Strikes Back(1985)
Stone Preston
42,016 PointsHere are some general tips that will help you pass the challenge:
To create an associative array with some keys and values:
$fruitArray = array("fruitName"=>"apple", "fruitColor"=>"red");
notice how the string that comes before the => is the key and the one that comes after the => is the value. so in this array with have one key called fruitName with a value of apple and another key called fruitColor with a value of red
to echo values in an associative array using its keys:
echo $fruitArray["fruitName"];
the code above will echo out the value that is associated with the key fruitName, which is "apple"
Susitha Herath Mudiyanselage
4,957 PointsSo far I've managed up to here but code checker says its wrong..
<?php $movie = array();
$movie["title"] = "The Empire Strikes Back";
?>
<h1><?php echo $movie["title"]?>(1985)</h1>
<table> <tr> <th>Director</th> <td>Robert Zemeckis</td> </tr> <tr> <th>IMDB Rating</th> <td>8.5</td> </tr> <tr> <th>IMDB Ranking</th> <td>53</td> </tr> </table>
Bella Ratmelia
Front End Web Development Techdegree Graduate 28,947 PointsYou need to add a semicolon after $movie["title"] so it'll be <?php echo $movie["title"]; ?>
Stone Preston
42,016 PointsActually the closing ?> implies a semicolon at the end, so it's not necessary in this case. It wouldn't hurt to add one though.
Susitha Herath Mudiyanselage
4,957 PointsThanks for your reply @Stone Preston I have passed the code challenge, the space between title and parenthesis was the problem. Thank you all for the replies...
Stone Preston
42,016 PointsStone Preston
42,016 Pointscan you please post the code you have tried so far