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

Gerti Kadillari
Gerti Kadillari
10,349 Points

PHP challenge Help

Challenge name Check if each student has a GPA of 4.0. If the student has a GPA of 4.0, use the students name variable to display "NAME made the Honor Role". If not, use the variable to display "NAME has a GPA of GPA".

My Code:

<?php

$studentOneName = 'Dave'; $studentOneGPA = 3.8;

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

//Place your code below this comment

if ($studentTwoGPA == 4.0) { echo "$studentTwoName made the Honor Role"; } else { echo "$studentTwoName didn't made the Honor Role"; } if ($studentOneGPA == 4.0) { echo "$studentOneName made the Honor Role"; } else { echo "$studentOneName has a $studentOneGPA GPA of GPA 4.0"; }

?>

Darrell Conklin
seal-mask
.a{fill-rule:evenodd;}techdegree
Darrell Conklin
Python Development Techdegree Student 22,116 Points
<?php

$studentOneName = 'Dave'; 
$studentOneGPA = 3.8;

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

//Place your code below this comment

if ($studentTwoGPA == 4.0) { 
   echo "$studentTwoName made the Honor Role"; 
} else { 
   echo "$studentTwoName didn't made the Honor Role"; 
} 

if ($studentOneGPA == 4.0) { 
   echo "$studentOneName made the Honor Role"; 
} else { 
   echo "$studentOneName has a $studentOneGPA GPA of GPA 4.0"; 
}

?>

3 Answers

Gerti Kadillari
Gerti Kadillari
10,349 Points

Thank you for the replays guyz... The thing is I completed the challenge...But when I try doing the challenge on my own text editor the result is the same as the challenge requires...but when I tried doing it using the workplace it gives me error..even tho i think my code is correct.

Darrell Conklin
seal-mask
.a{fill-rule:evenodd;}techdegree
Darrell Conklin
Python Development Techdegree Student 22,116 Points

Oh ok well if it's not working inside workspaces make sure that you named your file with a .php extension and that you saved your file before trying to view it.

The code you showed above is working code but as you displayed it above it wouldn't have passed the challenge. It's always good to provide as many details as possible.

Darrell Conklin
seal-mask
.a{fill-rule:evenodd;}techdegree
Darrell Conklin
Python Development Techdegree Student 22,116 Points

Also what browser are you using, I've had issues in the past with workspaces and certain browsers not wanting to work together even though it's been a while since I've ran into that issue

Gerti Kadillari
Gerti Kadillari
10,349 Points

Darrell Conklin... I set all good..the file is named with a .php extension im using chrome as my main browser. And Xampp as program to show the output at the browser.

Darrell Conklin
seal-mask
.a{fill-rule:evenodd;}techdegree
Darrell Conklin
Python Development Techdegree Student 22,116 Points

You don't need a web server client like Xampp to preview workspaces. I don't know how you have everything set up but I would start by disabling Xampp and restarting your computer and then try the code in workspaces.

Also what error are you getting?

Gerti Kadillari
Gerti Kadillari
10,349 Points

Darrell Conklin again thank you for the time...I passed the challenge the error that i was getting was that i must set $studentOneGPA or $studentTwoGPA == 4.0 ... but no problem it's all good now :D