我的代码确实有问题,但是当我仔细检查时,我找不到任何错误。
它说了解析错误,但是我不由自主地发现我做错了什么。 这是我的下面的代码。帮我解决这个问题。
//Add student
if (isset($_POST['add-btn'])) {
$fname = mysqli_real_escape_string($conn, $_POST['fname']);
$lname = mysqli_real_escape_string($conn, $_POST['lname']);
$age = mysqli_real_escape_string($conn, $_POST['age']);
$gender = mysqli_real_escape_string($conn, $_POST['gender']);
$contactno = mysqli_real_escape_string($conn, $_POST['contactno']);
$address = mysqli_real_escape_string($conn, $_POST['address']);
$emergencyCase = mysqli_real_escape_string($conn, $_POST['emergencyCase']);
$yearlevel = mysqli_real_escape_string($conn, $_POST['yearlevel']);
$sem = mysqli_real_escape_string($conn, $_POST['sem']);
$status = mysqli_real_escape_string($conn, $_POST['status']);
$email = mysqli_real_escape_string($conn, $_POST['email']);
$birthdate = mysqli_real_escape_string($conn, $_POST['birthdate']);
$studentdesc = mysqli_real_escape_string($conn, $_POST['studentdesc']);
if (!preg_match("/^[a-zA-Z]*$/", $fname) || !preg_match("/^[a-zA-Z]*$/", $lname) || !preg_match("/^[a-zA-Z]*$/", $gender) || !preg_match("/^[a-zA-Z]*$/", $status) {
header("Location: formview.php?------>Some-Character=Invalid");
exit();
} else {
if (!filter_var($email, FILTER_VALIDATE_EMAIL)) {
header("Location: formview.php?------>Email=Invalid");
exit();
} else {
$sql = "INSERT INTO students (firstname, lastname, age, gender, contactno, address, emergencyCaseContactNo, yearlvl, semester, status, email, birthdate, description)
VALUES ('$fname', '$lname', '$age', '$gender', '$contactno', '$address', '$emergencyCase', '$yearlevel', '$sem', '$status', '$email', '$birthdate', '$studentdesc');";
mysqli_query($conn, $sql);
$message = "New student added!";
echo "<script type='text/javascript'>alert('$message');</script>";
}
}
}
这是错误的意思。。解析错误:语法错误,意外的';'在第99行的C:\ xampp \ htdocs \ student-information \ server.php中