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 trialSusan Thatcher
1,217 Points(Unprintable)
I can't figure out where I went off the rails. I keep getting back "Bummer. You need to check the GPA of StudentOneName." (I didn't know Jeff Lebowski was teaching this course). I tried on my own. I looked at community answers. I tried yelling at the screen (not effective). Please tell this simple mind how I screwed up.
index.php
<?php $studentOneName = 'Dave'; $studentOneGPA = 3.8; ​ $studentTwoName = 'Treasure'; $studentTwoGPA = 4.0; ​ //Place your code below this comment If ($studentOneGPA == 4.0) { echo "$studentOneName . made the Honor Roll"; } else { echo "$studentOneName .had a GPA of . $studentOneGPA"; } If ($studentTwoGPA == 4.0) { echo "$studentTwoName . made the Honor Roll"; } else { echo "$studentTwoName . had a GPA of . $studentTwoGPA"; } ​ ?>
<?php
$studentOneName = 'Dave';
$studentOneGPA = 3.8;
$studentTwoName = 'Treasure';
$studentTwoGPA = 4.0;
//Place your code below this comment
If ($studentOneGPA == 4.0) {
echo "$studentOneName . made the Honor Roll";
} else {
echo "$studentOneName .had a GPA of . $studentOneGPA";
}
If ($studentTwoGPA == 4.0) {
echo "$studentTwoName . made the Honor Roll";
} else {
echo "$studentTwoName . had a GPA of . $studentTwoGPA";
}
?>
3 Answers
Steven Parker
231,275 PointsI see three issues:
- you wrote "If" (with capital "I") instead of "if" (lower-case "i") in two places
- you wrote "had a GPA" (past tense) instead of "has a GPA" (present tense) in two places
- you don't need the concatenation operator (".") inside a template string
Marleen Berg
22,524 PointsAlso, you wrote the variable name between qoutes..
<?php
echo "$studentOneName . made the Honor Roll";
?>
is not correct, it should be
<?php
$studentOneName = 'Dave';
echo $studentOneName ." made the Honor Roll";
?>
Steven Parker
231,275 PointsBetween the quotes (inside the template string) is fine, just don't also use the concatenation operator.
Susan Thatcher
1,217 PointsI thought that if you wanted it to echo the variable value, you need the double quotes.
Susan Thatcher
1,217 PointsOkay, FINALLY got it to work! (proper spacing? "You didn't say, 'Mother, may I?'")
Thank you both for weighing in.
Susan Thatcher
1,217 PointsSusan Thatcher
1,217 PointsThank you. I just stared at it and couldn’t see.
Susan Thatcher
1,217 PointsSusan Thatcher
1,217 PointsI've made the changes (or think I have) and I'm still getting the error message. (I have similar issues with loops in JavaScript. The lessons aren't sticking).
Will accept all help and advice. And a free kitten.
<?php $studentOneName = 'Dave'; $studentOneGPA = 3.8;
$studentTwoName = 'Treasure'; $studentTwoGPA = 4.0;
//Place your code below this comment if ($studentOneGPA == 4.0) { echo $studentOneName . "made the Honor Roll"; } else { echo $studentOneName . "has a GPA of ". $studentOneGPA; } ff ($studentTwoGPA == 4.0) { echo $studentTwoName . "made the Honor Roll"; } else { echo $studentTwoName. "has a GPA of ". $studentTwoGPA; }
?>