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 trialPedro nieto Sanchez
28,169 PointsWhat am I doing wrong in here?
What am I doing wrong here?
<?php $movie = array(
"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>
Pedro nieto Sanchez
28,169 PointsYes, and also to me. But for some reason I get the message that there is an error. And I can't go forward.
Chris McKirgan
5,666 PointsCan you please post the error you receive here? It's impossible to know what you're issue is unless you provide some more information.
Pedro nieto Sanchez
28,169 PointsThis is the error message that I am receiving.
"(X) Brummer! It looks like the title of the second movie is in the <h1>, but something else isn't quite right. Double-check the parentheses and the year."
I have also done a screenshot, is it possible to post an image here in the forum? I don't find the option to attach images.
Thanks.
Pedro nieto Sanchez
28,169 PointsHi I finally found it.
The problem was that i should have declared the array in this way.
<?php $movie = array();
$movie["title"] = "The Empire Strikes Back";
?>
Not the way I did.
jaja
Thanks for your time.
Chris McKirgan
5,666 PointsOh! What a silly evaluation by Treehouse. Glad you got your problem sorted. Its often about jigging the code around, well done on persisting :]
4 Answers
Chris McKirgan
5,666 PointsIs it that you have the movie year not set in the variable? You have (1985) sat next to the echoed variable. Your code works, but TeamTreehouse is not validating it as it is not quite what they've asked of you.
Try removing this and setting it in the title variable:
<?php $movie = array(
"title" => "The Empire Strikes Back (1985)"
);
?>
<h1><?php echo $movie["title"] ?></h1>
Pedro nieto Sanchez
28,169 PointsHi Chris.
I have tried that. And now I get this error message.
"Oops! It looks like Task 2 is no longer passing."
Meaning that the array it was correctly declared before.
Thanks.
Chris McKirgan
5,666 PointsI see, perhaps the title is set correctly, but they are just expecting the echoed title to be the only thing to be output in the h1 tag ? Often with these evaluations on this site it takes a bit of experimenting. This is actually a good thing, because with developing in a commercial environment this is often the course I take for small evaluations like this.
E.g.:
<?php $movie = array(
"title" => "The Empire Strikes Back"
);
?>
<h1><?php echo $movie["title"] ?></h1>
Pedro nieto Sanchez
28,169 PointsThat didn't work either.
This is the original question: "By the end of this challenge, we'll REMOVE from the page all the information about the original movie ("Back to the Future") and REPLACE it with information about the new movie ("The Empire Strikes Back"). Right now, the <h1> element has the title of the original movie as a static piece of text. Replace that with a PHP command that INSTEAD displays the title of the new movie from the array. (Be sure to leave the <h1> tags, the parentheses, and the year intact.)"
Did you manage to pass this question? Or do you think is a bug of teamtreehouse?
Thanks.
Amaan Marfatia
11,132 Points<?php $movie = array(
"title" => "The Empire Strikes Back"
);
?>
<h1><?php echo $movie["title"]." (1985)" ?></h1>
I tried this and it worked. I guess they want you to keep the date. And later when you need to replace the date, don't forget to keep the parenthesis.
Chris McKirgan
5,666 PointsChris McKirgan
5,666 PointsThis executes and renders as expected to me. Can you clarify what exactly is wrong? What are you expecting? Do you get any errors?