I am having trouble with nested php statements. I am getting the error:
Parse error: syntax error, unexpected 'if' (T_IF)
and it is the commented line below.
Is this because it is nested or because the if statement preceding it needs a colon or semi-colon to finish it?
<?php
$error = 0;
$error_note = "";
if(isset($_GET['carts'])) {
// Set Carts Variable
$carts = $_GET['carts'];
// Check for Valid Numeric Value
if (is_numeric($carts)) {} else {
$error++;
$error_note .= "Please enter a valid number.";
}
// Set Calculations for Sustainability
if($error == 0) { //this line
$NumTruckLoads = ceil($carts / 60);
$NumOtherTruckLoads = ceil($carts / 20);
$MPG = $NumTruckLoads * 1.66667;
$MPGOther = $NumOtherLoads * 1.66667;
}
} else {
$carts = 1000;
$error++;
}
?>
Aucun commentaire:
Enregistrer un commentaire