Welcome to the Treehouse Community
The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.

budoor ayhd
1,471 PointsHello, where the error in this code!
where the error in this code! the Q is : Check if each student has a GPA of 4.0. If the student has a GPA of 4.0, use the student's name variable to display "NAME made the Honor Roll". If not, use the variable to display "NAME has a GPA of GPA".
<?php
$studentOneName = 'Dave';
$studentOneGPA = 3.8;
$studentTwoName = 'Treasure';
$studentTwoGPA = 4.0;
if ( $studentTwoGPA = 4.0 )
{
echo "$studentTwoName made the Honor Roll";
}
else {
echo "$studentTwoName has a GPA of GPA";
}
?>

Umesh Ravji
42,362 PointsJust to add to the previous comment, you are also missing the value of the GPA variable in the secound echo statement.
5 Answers

Zoltán Rajcsányi
6,426 PointsThe soulution is that:
<?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}";
}
if ($studentTwoGPA == 4.0) {
echo "{$studentTwoName} made the Honor Roll";
} else {
echo "{$studentTwoName} has a GPA of {$studentTwoGPA}";
}
?>
So, I investigated all of the students and criteria... :)

budoor ayhd
1,471 PointsThanks Zoltán Rajcsányi :)

carlos almanzar
1,935 Pointswhy is these '{}' used around the $studentOneName and $studentTwoName?

Zoltán Rajcsányi
6,426 Pointsre: why is these '{}' used around the $studentOneName and $studentTwoName?
I like "${name_of_variable}" full format embeded var in string because:
- easier recognise that is an embeded variable in string
- always work, where the normal $varible it doesn't
- unify my code

budoor ayhd
1,471 Pointsbut still give me error!!

Umesh Ravji
42,362 PointsCould you please post your updated code so someone can see :)

Leon Segal
14,754 PointsDid you change those 2 things?
Here, like this:
<?php
$studentOneName = 'Dave';
$studentOneGPA = 3.8;
$studentTwoName = 'Treasure';
$studentTwoGPA = 4.0;
if ( $studentTwoGPA == 4.0 ) {
echo "$studentTwoName made the Honor Roll";
} else {
echo "$studentTwoName has a GPA of $studentTwoGPA";
}
This gives me the following message on my local machine:
Treasure made the Honor Roll
If I change $studentTwoGPA to 3.9, I get the message:
Treasure has a GPA of 3.9
Bingo Bongo - working! :)

budoor ayhd
1,471 PointsThe same error، look to the photo in the link:
https://www.dropbox.com/s/bisa43kkmp2fdsj/Code%20Challenge%20%20Conditionals.png?dl=0

Leon Segal
14,754 PointsOh - the question is asking for student 1, not student 2!
Change the 3 lines in the if statement and it should work...

budoor ayhd
1,471 PointsOMG!! the same error

charquise
1,274 PointsBudoor, you only checked for student two, you have to check for student one also. Hope this helps! :)
Leon Segal
14,754 PointsLeon Segal
14,754 PointsIn the if statement you are assigning with
=
.Compare values with
==
or===
.