开发者

Parse Error: syntax error: unexpected '{' [closed]

开发者 https://www.devze.com 2023-03-28 05:59 出处:网络
This question is unlikely to help any future visitors; it is only relevant to a small geographic area, a specific moment in time,or an extraordinarily narrow situation that is not generally applic
This question is unlikely to help any future visitors; it is only relevant to a small geographic area, a specific moment in time, or an extraordinarily narrow situation that is not generally applicable to the worldwide audience of the internet. For help making this question more broadly applicable, visit the help center. Closed 11 years ago.

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.


Firstly, this line is missing a closing bracket:

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

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:

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.

Hope that helps.


You are missing a right parenthesis in the line:

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


Change

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

to

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

精彩评论

暂无评论...
验证码 换一张
取 消