解析错误:语法错误,意外的'}'
问题描述:
需要一些帮助下面的代码。这是php代码的一部分,用于检查用户标识和加密密码的组合是否已经存在于数据库中。所以当我用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")
}
?>
谢谢:)
答
你忘了;
此行之后header("Location: /ClassRegistration/Maintenance/systementry.php")
正确的代码应该是:
header("Location: /ClassRegistration/Maintenance/systementry.php");
上futher注: 请不要使用的mysql_query连接到你的数据库。这是非常不安全的,将在下一个版本的PHP中被删除。这意味着你的代码很快就会中断。
请看以下页面以获取更多信息:MySQL vs MySQLi when using PHP
答
应用分号头功能之后
header("Location: /ClassRegistration/Maintenance/systementry.php");
您在哪行中出错? –
最后一个标题()行缺少分号? –
你甚至谷歌的错误? – Mike