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 Basic PHP Website (2018) Building a Media Library in PHP Variables and Conditionals

Andrew Lenti
seal-mask
.a{fill-rule:evenodd;}techdegree
Andrew Lenti
Front End Web Development Techdegree Student 7,193 Points

unsuccessful if statement (question #3)

Hello. Firstly upon trying to answer the third (and last question) in the last section of 'Build a Basic PHP Website, I continuously get 'kicked out' with a strange error message and am forced to start from the beginning. This issue was present yesterday as well as today. The problem which I cannot seem to resolve (and perhaps this is why the issue is persisting) regards the if statement with the cookie dough ice cream. I am trying to create an if statement that states if the variable $flavor is equal to 'cookie dough' then include the statement 'Hal's favourite flavor is also cookie dough' I am stuck on this one.. My code is as follows.. Please help for I would like to go ahead with my studies but am blocked here for two days now.

<?php $flavor = "pistacchio"; ?>

<p>Your favorite flavor of ice cream is <?php echo $flavor ?>.</p>

if ( $flavor == "cookie dough" {

<p>Hal's favorite flavor is <?php echo $flavor ?>, also!</p>

}

index.php
<?php

echo "<p>Your favorite flavor of ice cream is ";
echo "vanilla";
echo ".</p>";
echo "<p>Hal's favorite flavor is cookie dough, also!</p>";

?>

1 Answer

Chase Marchione
Chase Marchione
155,055 Points

Hi Andrew,

Looks like your if statement is missing a closing parenthesis. Also, you'll want to be sure to echo, because it's needed to output the string for the user to be able to read it.

<?php
$flavor = "pistacchio";
echo "<p>Your favorite flavor of ice cream is ";
echo $flavor;
echo ".</p>";
if ($flavor == "cookie dough") {
  echo "<p>Hal's favorite flavor is cookie dough, also!</p>";
};
?>

Hope this helps!