解析错误:语法错误:意外的"{" [英] Parse Error: syntax error: unexpected '{'

查看:637
本文介绍了解析错误:语法错误:意外的"{"的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有这段处理用户的代码,然后将其重定向到用户主页.

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."
        }
    }
?>

我得到了错误:

Parse error: syntax error, unexpected '{' in userprocess.php on line 11

有人可以告诉我这个问题吗?我认为这可能是if语句中的if内,但是我该怎么做呢?谢谢.

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.

推荐答案

首先,该行缺少右括号:

Firstly, this line is missing a closing bracket:

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

计算()的数量-它们需要匹配.

Count the number of ( and ) -- they need to match.

解决此问题时,仍然会出错,因为PHP语句需要以分号结尾.

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:

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

您需要先修复它们,然后才能运行程序而不会出现语法错误.

You need to fix them all before you'll be able to run the program without syntax errors.

希望有帮助.

这篇关于解析错误:语法错误:意外的"{"的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆