解析错误:语法错误:意外的'{'
我有这段代码可以处理用户然后将他们重定向到用户主页。
<?php
$username = $_POST['username'];
$password = $_POST['pwd'];
$file = file_get_contents("userdb.html");
if(!strpos($file, $username)) {
echo "Your username was not found in our database. Please go back and try again.";
} else {
echo "Redirecting...";
if (md5($password) == !strpos($file, (md5($password))) {
echo "Redirecting..."
header ('Location: ./userhome.php')
} else {
print "Whoops! Your password seems to be incorrect. Go back and try again."
}
}
?>
我收到错误:
Parse error: syntax error, unexpected '{' in userprocess.php on line 11
有人可以告诉我问题吗?我认为这可能是 if 语句中的 if ,但是我能做些什么来替代呢?谢谢。
I have this code that processes a user then redirects them to the user homepage.
<?php
$username = $_POST['username'];
$password = $_POST['pwd'];
$file = file_get_contents("userdb.html");
if(!strpos($file, $username)) {
echo "Your username was not found in our database. Please go back and try again.";
} else {
echo "Redirecting...";
if (md5($password) == !strpos($file, (md5($password))) {
echo "Redirecting..."
header ('Location: ./userhome.php')
} else {
print "Whoops! Your password seems to be incorrect. Go back and try again."
}
}
?>
And I get the error:
Parse error: syntax error, unexpected '{' in userprocess.php on line 11
Could someone tell me the problem please? I think it may be the if inside of if statement, but what can I do for an alternative? Thanks.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
首先,这一行缺少一个右括号:
计算
(
和)
的数量——它们需要匹配。当您修复此问题时,您仍然会收到错误,因为 PHP 语句需要以分号结尾。
以下所有行都缺少分号:
您需要先修复它们,然后才能在没有语法错误的情况下运行程序。
希望有帮助。
Firstly, this line is missing a closing bracket:
Count the number of
(
and)
-- they need to match.When you fix this, you'll still get errors, because PHP statements need to end with semi-colons.
All of the following lines are missing their semi-colon:
You need to fix them all before you'll be able to run the program without syntax errors.
Hope that helps.
您在该行中缺少右括号:
You are missing a right parenthesis in the line:
更改
为
Change
to