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

Help

I keep geting this message

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.

this is the code i wrtoe

<?php $movie = array(); $movie["title"] = "The Empire Strikes Back"; ?>

<h1><?php echo $movie["title"] ?></h1>

6 Answers

Thomas Ireland
PLUS
Thomas Ireland
Courses Plus Student 8,216 Points

Hi, Reshard

Did you leave the year in the parentheses after the closing php tag? Also, I would have specified the key=>value pair in the array e.g. <?php $movie = array("title" => "The Empire Strikes Back"); ?>

I'm no expert, but I hope that helps.

Cheers

Tom

Hey, Thomas

I WIll give it a try, thanks for the replay , and its the same things to do it like e.g. $movie[title] = "The empire stikes back" right ?

Thomas Ireland
PLUS
Thomas Ireland
Courses Plus Student 8,216 Points

Hey, Reshard

Sure! You can create an array key => value pair that way, too.

I think for the purposes of the exercise, judging by what you said you wrote, you've left out the year in the parentheses.

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

Cheers

Tom

I finally got past that part now, im trying to add the key for the year after the title so heres my code... what am i doing wrong

<?php $movie = array( "title" => "The Empire Strikes Back", "year" => "1980", ); ?> <h1><?php echo $movie["title"] ?> <?php echo $movie"year"?> </h1>

Thomas Ireland
PLUS
Thomas Ireland
Courses Plus Student 8,216 Points

You need to keep the parentheses and it looks like you missed the square brackets and semi-colon.. One way would be to write it like this:

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

Ok just typed what you did an still wont pass me !

Thomas Ireland
PLUS
Thomas Ireland
Courses Plus Student 8,216 Points

Weird. I just tested it and it was okay. Are you making sure you close the first PHP statement where you're echoing the title and writing the second statement inside of the parentheses? Make sure you haven't missed a semi-colon and have included the array key in the square brackets, too. I always miss stuff off like that and it's a pain to debug sometimes, even though it's so simple. :)