This forum is now read-only. Please use our new forums at discuss.codecademy.com.

Conditionals and Control Flow Forum

View Course » View Exercise

301 points
Picture
Submitted by
Nick Basile
over 4 years ago

The exercise won't let me pass even though I think the code is right.

Here's my code:

<?php
$items = 8; // Set this to a number greater than 5!
if ($items > 5) {
echo "You get a 10% discount!";
}
else ($items < 5) {
echo "You get a 5% discount!";
}
?>

Here's the message it gives me:

Oops, try again.
Did you remember to include the else keyword?

It also shows this in the results box:

PHP Parse error: syntax error, unexpected '{' in /root/adapter/runners/runner.php(47) : eval()'d code on line 12

Where is the mistake?


2 votes

permalink

i dont think you need the ($items < 5) after else
just do
else {
echo "You get a 5% discount!";
}

45 points
Picture
Submitted by
Brian Moon
over 4 years ago


0 votes

permalink

Thank you, that resolved the issue.

301 points
Picture
Submitted by
Nick Basile
over 4 years ago