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

时间:2015-11-06 12:49:58

标签: php validation xampp

需要以下代码的帮助。这是PHP代码的一部分,用于检查用户ID和加密密码的组合是否已存在于数据库中。因此,当我使用Xampp运行代码时,出现错误 - 解析错误:语法错误,意外'}'发生。

<?php
//Determine if the User ID and password are on file.
    $row = mysql_fetch_object($result);
    $db_userid = $row->admin_id;
    $db_password = $row->admin_password;
    $name = $row->admin_name;

if($db_userid != $userid || $db_password != $encryptpasswd){

    //If not on file, add record to administrator table.
    $query = "INSERT INTO administrator(admin_id, admin_password, admin_name)
                VALUES('$userid','$encryptpasswd','$name')";
    $result = mysql_query($query)
        or die("Insert to administrator failed." . mysql_error());

    //Return to adminAuthen.php
    header( "Location: adminAuthen.php");
}
else{
    //If on file, set the session variable, and enter site.
    $_SESSION["name"] = $name;
    $_SESSION["retry"] = "admit";
    $_SESSION["time"] = time();
    header( "Location: /ClassRegistration/Maintenance/systementry.php")
}
?>

谢谢:)

2 个答案:

答案 0 :(得分:0)

在标题功能

之后应用半冒号

header( "Location: /ClassRegistration/Maintenance/systementry.php");

答案 1 :(得分:0)

您在此行;

之后忘记了header( "Location: /ClassRegistration/Maintenance/systementry.php")

正确的代码应该是:

header( "Location: /ClassRegistration/Maintenance/systementry.php");

更进一步说明: 请不要使用mysql_query连接到您的数据库。这非常不安全,将在下一版本的PHP中删除。这意味着您的代码很快就会破解。

请查看以下页面以获取更多信息:MySQL vs MySQLi when using PHP