PHP ELSEIF Parse Error. What is causing this?

  • Thread starter Thread starter Danny B
  • Start date Start date
D

Danny B

Guest
I receive the following error for this code.

Parse error: parse error in F:\xampplite-win32-1.7.0\xampplite\htdocs\d-1b.php on line 26

Note: I can comment out all the elseifs and the code will work, it will give me the expected results for A and it will give me the expected error message if one of my values is not numeric. I am confused as to why I receive parse errors upon moving into my elseifs. Also even were I to change the elseifs to just regular ifs I still receive the same error.

<?php
extract($_REQUEST, EXTR_SKIP);
if (is_numeric($g1) and is_numeric($g2) and is_numeric($g3))
{
$gAve = (round(($g1 + $g2 + $g3)/3));
if ($gAve >= 90)
{
print("<h1>$gAve A</h1>");
}
elseif ($gAve >=80 and <=89)
{
print("<h2>$gAve B</h2>");
}
elseif ($gAve >=70 and <=79)
{
print("<h3>$gAve C</h3>");
}
elseif ($gAve >=60 and <=69)
{
print("<h4>$gAve D</h4>");
}
elseif ($gAve <=59 and >=0)
{
print("<font color='red'><h5>$gAve F<br />You must not fail!!! DO BETTER!!!!!!</h5>");
}
else
{
print("negative numbers are not acceptable entries");
}

}
else
{
print ("please enter numeric data only");
}
?>
BTW: Line 26 is where the first elseif appears.
 
elseif ($gAve >=80 and <=89)

So, if gAve is greater than or equal to 80 AND ... is less than or equal to 89.

WHAT is less than or equal to that?

Each condition is independent, the left hand side of the condition doesn't automatically appear in the next one.
 
Back
Top