Hello,
I have a very aggrivated unexped T_ELSE on the last else in this function.
function QueryPeople($stringQuery, $table, $max, $cmd) {
$con = mysqli_connect("localhost","user","password", "host");
if ($cmd == "Option1") {
$SearchSQL = "SELECT signature, firstname, birthdate FROM $table WHERE lower(signature) LIKE ?" . $max;
if ($fetchData = $con->prepare($SearchSQL)) {
$fetchData->bind_param("s", "%".$stringQuery."%");
$fetchData->execute();
$fetchData->bind_result($signature, $firstname, $birthdate);
$rows = array();
}
} else if ($cmd == "Option2") {
$searchSQL = "SELECT signature, firstname, birthdate FROM $table WHERE birthdate = ?" . $max;
if ($fetchData = $con->prepare($searchSQL)) {
$fetchData->bind_param(":birthdate", $stringQuery);
$fetchData->execute();
$fetchData->bind_result($signature, $firstname, $birthdate);
$rows = array();
}
}
while ($fetchData->fetch()) {
$row = array(
'signature' => $signature,
'firstname' => $firstname,
'birthdate' => $birthdate,
);
$rows[] = $row;
}
return $rows;
} else { // <-- This else doesn't have an if
print_r($con->error); // <-- This else doesn't have an if
} // <-- This else doesn't have an if
}
I seriously cannot understand why this is happening. Both the if blocks should be self contained, and both are closed, and then it should go to the wile, and only the if if something loos fishz?