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 trialbenjamin sanchez
6,101 PointsPHP-basics-2 - $StudentOneGPA & $StudentTwoGPA - I don't understand what i'm doing wrong - the output seems alright.
For some reason it keeps telling me I have to display is 'using name variables' or something like that - i'm trying to make the $studentOneName variable = the output, but it still doesn't work! Any advice would be appreciated :)!
<?php
$studentOneName = 'Dave';
$studentOneGPA = 3.8;
$studentTwoName = 'Treasure';
$studentTwoGPA = 4.0;
//Place your code below this comment
if($studentOneGPA === 4.0){
$studentOneName = "$studentOneName made the Honor Role";
} else {
$studentOneName = "$studentOneName has a GPA of $studentOneGPA";
}
if($studentTwoGPA === 4.0){
$studentTwoName = "$studentTwoName made the Honor Role";
} else {
$studentTwoName = "$studentTwoName has a GPA of $studentTwoGPA";
}
echo $studentOneName;
echo $studentTwoName;
?>
1 Answer
Jennifer Nordell
Treehouse TeacherHi there! The biggest problem here is that you're overwriting their variables. You may not do that. Even if functional, it will cause the challenge to fail. So this line here:
$studentOneName = "$studentOneName made the Honor Role";
should be a direct echo
echo "$studentOneName made the Honor Role";
Try it again without writing over their variable values. Hope this helps!
benjamin sanchez
6,101 Pointsbenjamin sanchez
6,101 PointsThank you for your reply - I tried to do as you said - here is a snippet of the code I used
But I keep getting this -> Bummer! Use the variables to display the message
Jennifer Nordell
Treehouse TeacherJennifer Nordell
Treehouse Teacherbenjamin sanchez you're correct! I forgot to point that out. For whatever reason, the triple equals will cause the challenge to fail (as will another bug). I sent in a bug report on Friday, so I hope it's fixed soon! I posted a working solution that you can view here.
Hope this helps!
benjamin sanchez
6,101 Pointsbenjamin sanchez
6,101 PointsThank you :D ! It was the '===' I too hope it is fixed soon. See you around o/