解析错误:语法错误:意外'}'

时间:2015-02-13 10:29:40

标签: php mysql mysqli

标题中的错误有一个小问题,但所有括号都匹配,所以我不知道它为什么显示此错误。谁知道为什么?

代码是:

<?php

    session_start();
    require_once 'db/connect.php';
    //require_once 'entryformsuccess.php';
    echo $_SESSION['Username'] . ' logged in successfully ' . ' <br> ';

        if ($student_delete = $con->query("SELECT Student.Form, Teacher.Form, Forename, Surname, Student_ID, Username " .
                                            "FROM student, teacher " . 
                                                "WHERE Student.Form = Teacher.Form AND Teacher.Username = '" . $_SESSION['Username'] . "'")) {

            if (isset($_POST['Student_ID']))    {   
                $checkbox = $_POST['checkbox']; 

                for ($i=0;$i<count($checkbox);$i++) {
                    $del_student = $checkbox[$i];
                    $query= $con->query("DELETE FROM users WHERE Student_ID = 'Student_ID'")


                }                           

            }
        }       

?>

3 个答案:

答案 0 :(得分:1)

您错过了

末尾的;
$query= $con->query("DELETE FROM users WHERE Student_ID = 'Student_ID'")

答案 1 :(得分:0)

请更新它。

<?php

        session_start();
        require_once 'db/connect.php';
        //require_once 'entryformsuccess.php';
        echo $_SESSION['Username'] . ' logged in successfully ' . ' <br> ';

            if ($student_delete = $con->query("SELECT Student.Form, Teacher.Form, Forename, Surname, Student_ID, Username " .
                                                "FROM student, teacher " . 
                                                    "WHERE Student.Form = Teacher.Form AND Teacher.Username = '" . $_SESSION['Username'] . "'")) {

                if (isset($_POST['Student_ID']))    {   
                    $checkbox = $_POST['checkbox']; 

                    for ($i=0;$i<count($checkbox);$i++) {
                        $del_student = $checkbox[$i];
                        $query= $con->query("DELETE FROM users WHERE Student_ID = 'Student_ID'");


                    }                           

                }
            }       

    ?>

答案 2 :(得分:0)

我认为你在这行末尾缺少一个分号:

$query= $con->query("DELETE FROM users WHERE Student_ID = 'Student_ID'");