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 trial

PHP PHP Basics Daily Exercise Program Conditionals

Error message says to use variables to display, but I thought I did. What did I do wrong?

I am working on displaying the variables by their names, the code I have written (however primitively) displays the correct information and uses the variable names, but an error is still thrown. I am just curious as to how I should be creating my string to conform with what the system is looking for.

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 \n";
}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 $studentTwoName";
}
?>

3 Answers

You have an extra \n at the end of the first string and an extra space at the end of the second (The system can be quite fussy and needs it to be EXACTLY what they want.

Also, you have $studentTwoName at the end of the fourth string and this should be $studentTwoGPA

Thank you for taking the time to view this and respond Mr. Anthony. I have made the changes you mentioned and it is still throwing an Incorrect output error. Here is the refactored code:

<?php $studentOneName = 'Dave'; $studentOneGPA = 3.8;

$studentTwoName = 'Treasure'; $studentTwoGPA = 4.0;

//Place your code below this comment if($studentOneGPA == 4.0){ echo "$studentOneName has made the Honor Roll"; } else { echo "$studentOneName has a GPA of $studentOneGPA"; }

if($studentTwoGPA == 4.0){ echo "$studentTwoName has made the Honor Roll"; } else { echo "$studentTwoName has a GPA of $studentTwoGPA"; } ?>

It's amazing how easily I miss some of the simple mistakes I make, if I made anymore here I apologize, but I can't see them. I definitely realized how fickle the system is on another challenge. Thanks again for your time.

It's not:

NAME 'has' made the Honor roll

but

NAME made the Honor Roll

Oh man, I have much further to go than I thought. You're suggestions and help worked perfectly and I really appreciate it. I will work more on my attention to detail. Thanks again and have a good day.