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 Build a Simple PHP Application Listing Inventory Items Associative Arrays

li guopeng
li guopeng
8,873 Points

code challenge

Right now, the <h1> element has the year of the original movie as a static piece of text. Replace that with a PHP command that INSTEAD displays the year of the new movie from the array. (Be sure to leave the parentheses intact.)

Thank you! I don't find this error. :)

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

no need to get fancy just echo the year were the 1985 is.

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

2 Answers

Shaun Dixon
Shaun Dixon
10,944 Points

ah ok I see it, you have too many echos in your code there

You dont need an echo before movie["year"] Try this one below:

<h1><?php echo $movie["title"]."(". $movie["year"].")"?></h1>
Shaun Dixon
Shaun Dixon
10,944 Points

I think the problem you have is down to the challenge asking you to replace the year with PHP code instead of displaying it within the HTML.

If you look at your code below:

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

You have the echo.$movie["year"] asking to display the year of the movie but then also after your closing ?> you have "(1985")

try replacing it with

<h1><?php echo $movie["title"]."(".echo $movie["year"].")";?></h1>
li guopeng
li guopeng
8,873 Points

It doesn't work. I think there gonna be another error.