PHP PHP Arrays and Control Structures PHP Conditionals School's Out

June Westerfield
June Westerfield
2,138 Points

I'm getting an error even though my code looks exactly like instructors

When I save and run the script, I'm getting this error: PHP Parse error: syntax error, unexpected 'else' (T_ELSE), expecting end of file in /home/treeho use/workspace/school.php on line 33

But my code seems EXACTLY identical to the instructors (unless I'm missing something because I'm looking too hard.)

MY CODE (FROM LINE 29-40): if (!$firstName || !$lastName) { echo 'Please enter a student name'; } elseif ($currentGrade < 9 || $currentGrade > 12); { echo 'this is only for high school students. Please enter a grade between 9 and 12'; } else { if ($finalAverage < .70) { $messageBody = 'We look forward to seeing you at summer school, beginning July 1st!'; } else { switch ($currentGrade) { case 9: $messagebody ='Congratulations on completing your freshman year in High School! We’ll see you on September 1st for the start of your sophomore year!'; break;

2 Answers

Jake Obrien
Jake Obrien
3,870 Points

You've put a ; after your currentGrade elseif. Should just be a {