意外的$结束

1 php

我有这个错误:

解析错误:语法错误,第57行的/...../student.php中的意外$结束

注意:"student.php"中的行只有56行,所以错误出现在另外一行!

<?php
session_start();
if(!isset($_SESSION['user_login']))
    include('login.php');
else
    {?>
    <a href=student.php?add=1>????? ????</a><br>
    <a href=student.php?edit=1>????? ?????? ????</a><br>
    <?php
    if($_GET['add'] ==1)
        {?>
        <form action="student.php?add=2" method="POST">
        <input type="text" name="name" size="25" maxlength="50"> ??? ??????:
        <br>
        <input type="text" name="birthday" size="25" maxlength="50"> ????? ???????:
        <br>
        <input type="text" name="phone" size="25" maxlength="50"> ??? ??????:
        <br>
        <input type="text" name="mobile" size="25" maxlength="50"> ??? ?????? ??????:
        <br>
        <input type="text" name="email" size="25" maxlength="50"> ?????? ??????????:
        <br>
        <input type="text" name="comment" size="25" maxlength="100"> ???????:
        <br>
        <input type="submit" value="???">
        <input type="reset" value="???">
        </form>
        <?php
        }
    else if($_GET['add'] ==2)
        {
        $name = $_POST['name'];
        $birthday = $_POST['birthday'];
        $phone = $_POST['phone'];
        $mobile = $_POST['mobile'];
        $email = $_POST['email'];
        $comment = $_POST['comment'];
        $add = "INSERT INTO student(S_ID, S_Name, S_DOB, S_HomeTele, S_Mobile, S_Email, S_Comment) VALUES(NULL, '$name','$birthday','$phone','$mobile','$email','$comment')";
        $addq = MYSQL_QUERY($add);
        if($addq)
            {
            echo"?? ????? ?????? ?????<br>";
            echo"<a href=student.php?add=1>???? ??? ?????? ???? ???</a><br>";
            echo"<a href=student.php>???? ??? ?????? ????? ?????? ??????</a><br>";
            echo"<a href=admin.php>???? ??? ?????? ?????? ?????? ????? ??????</a><br>";
            }
        else
            {
            echo"<br>???? ???? ?? ??? ????? ??????";
            echo"<a href=student.php?add=1>???? ??? ?????? ???? ???</a><br>";
            echo"<a href=student.php>???? ??? ?????? ????? ?????? ??????</a><br>";
            echo"<a href=admin.php>???? ??? ?????? ?????? ?????? ????? ??????</a><br>";         
            }
        }
?>
Run Code Online (Sandbox Code Playgroud)

Sco*_*ott 6

该错误意味着有一个大括号{没有匹配的结束大括号.它到达文件的末尾并没有找到一个,这就是为什么它将它报告为文件的最后一行之后的原因.

缺少}第一个else区块的关闭.将一个添加到文件的最后一行(在结束之前?>)应该可以解决问题.