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

PHP

varis darasirikul
varis darasirikul
10,832 Points

Troubles with Simple PHP Application Challenge task 3 about associative array

By the end of this code 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.)

And i already wrote this below.

<h1><?php echo $movie["title"]; ?>(1985)</h1>
<?php
$movie = array("title" => "The Empire Strikes Back");
?>
<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>

It doesnΒ΄t work. and i don't know what wrong? and this is link to a Challenge task (task 3) http://teamtreehouse.com/library/build-a-simple-php-application/listing-inventory-items/associative-arrays

Andrew Shook
Andrew Shook
31,709 Points

What is your question?

varis darasirikul
varis darasirikul
10,832 Points

the 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 tags, the parentheses, and the year intact.)

Andrew Shook
Andrew Shook
31,709 Points

Never mind, for some reason it took my browser a few seconds to load you entire post.

4 Answers

Andrew Shook
Andrew Shook
31,709 Points

I see the problem now. You need to move your php code block that contains the array to the top of your file. The way you have it written, you can not use $movie['title'] in the h1 tag because you have declare that variable yet or defined it. Cut and paste your php block and put it at the top of the file.

Andrew Shook
Andrew Shook
31,709 Points

I believe the problem is that you don't have a space between the title and the year. Try this:

<h1><?php echo $movie["title"]; ?> (1985)</h1>