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.

PHP PHP Basics Daily Exercise Program Conditionals

(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"; } ​ ?>

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";
}

?>

3 Answers

Steven Parker
Steven Parker
212,140 Points

I 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

Thank you. I just stared at it and couldn’t see.

I'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; }

?>

Marleen Berg
Marleen Berg
22,524 Points

Also, 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
Steven Parker
212,140 Points

Between the quotes (inside the template string) is fine, just don't also use the concatenation operator.

I thought that if you wanted it to echo the variable value, you need the double quotes.

Okay, FINALLY got it to work! (proper spacing? "You didn't say, 'Mother, may I?'")

Thank you both for weighing in.