解析错误:语法错误:意外的'{'

我有这个处理用户的代码,然后将它们重定向到用户主页。

<?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 (md5($password) == !strpos($file, (md5($password))) {

计算()的数量 - 他们需要匹配。

当你解决这个问题时,你仍然会得到错误,因为PHP语句需要以分号结尾。

以下所有行均缺少分号:

echo "Redirecting..."
header ('Location: ./userhome.php')
print "Whoops! Your password seems to be incorrect. Go back and try again."

您需要先解决它们,然后才能在没有语法错误的情况下运行程序。

希望有所帮助。


您错过了该行中的右括号:

if (md5($password) == !strpos($file, (md5($password))) {

<?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.";
        }
    }
?>
链接地址: http://www.djcxy.com/p/11871.html

上一篇: Parse Error: syntax error: unexpected '{'

下一篇: php