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!

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


Can anyone find the problem?

Hello Frogs, I'm having trouble with the last question of the last challenge of the second php chapter. Whatever I try just will not work! Any ideas?

I'm having trouble... http://i.imgur.com/44Gnx.png

3 Answers

Michael Noga
Michael Noga
4,341 Points

Hi Andrew,

It looks like you have two issues here, one is when you're setting the variable $flavor, the other is when you are trying to echo that same variable.

When you set a variable to be a string, you need to surround that string with double quotes. So it should look like this:

$flavor = "cookie dough";

When you are trying to access the value of a variable, like when you echo one, you do not need to surround it with quotes, if you do then php will think it is a string and not a variable. So it should look like this:

echo $flavor;

The rest of your code looks good. Hope this helps!

Randy Hoyt
Randy Hoyt
Treehouse Guest Teacher

Hey Andrew,

Michael's right. Right now, the code isn't valid PHP. Putting "cookie dough" in quotation marks will fix that.

Once you get the code valid, you should encounter one other problem. I intended for the whole second sentence to be inside the conditional. Here are the two scenarios:

(1) If your favorite flavor is something like rocky road, the page should display this:

Your favorite flavor of ice cream is rocky road.

(2) If your favorite flavor is cookie dough, the page should display this:

Your favorite flavor of ice cream is cookie dough. Randy's favorite flavor is cookie dough, also! 

(I suspect you had that right in an earlier attempt; otherwise, you probably wouldn't have passed step three.)

@Michael + @Randy woooh teamwork!