开发者

php unexpected T_IS_NOT_EQUAL error [closed]

Closed. This question is not reproducible or was caused by typos. It is开发者_如何学运维 not currently accepting answers.

This question was caused by a typo or a problem that can no longer be reproduced. While similar questions may be on-topic here, this one was resolved in a way less likely to help future readers.

Closed 8 years ago.

Improve this question

I am trying to make a php script which will accept a password text and will delete the relevant data from the database. I get this error when i load the script

syntax error, unexpected T_IS_NOT_EQUAL in /home2/krisindi/public_html/deletead.php on line 4

    <?php
$password = $_POST["password"];

if ( $password ) != 0 )
        {
                $id = $data->select ("Classified", "AdID", array ("Password => ($password)));
                $data->delete ( "AdExtraField" , array ( "AdID" => intval ( $id["AdID"] ) ) ) ;
                $data->delete ( "Classified" , array ( "Password" => ( $password ) ) ) ;
                exec ( "chmod ../media/ 777" ) ;

                $image_file = "../media/cls_".$id["AdID"]."_520.jpg" ;
                if ( file_exists ( $image_file ) )
                        unlink ( $image_file ) ;

                for ( $i = 1 ; $i <= 5 ; $i++ )
                {
                        $image_file = "../media/cls_".$id["AdID"]."_".$i."_520.jpg" ;
                        if ( file_exists ( $image_file ) )
                                unlink ( $image_file ) ;
                }

                exec ( "chmod ../media/ 755" ) ;

                $_SESSION["str_system_message"] = "Classified deleted successfully." ;
        }

?>

<html>
<head>
<title>Personal INFO</title>
</head>
<body>
<form method="post" action="<?php echo $PHP_SELF;?>">
Password:<input type="text" size="12" maxlength="12" name="password">:<br />
<input type="submit" value="submit" name="submit"><br />
</form><br />


Line 4:

    <?php
$password = $_POST["password"];

if ( $password ) != 0 )
               ^
               Mismatched parenthesis

Update

Given that the question is getting negative votes, I'll improve my answer to make it more generalizable. You get a syntax error when your PHP code is not even valid PHP code (normally, because of a typo). In such case, the code won't even start running. Applied to the current situation, the first conclusion is that it doesn't matter what the script tries to accomplish since it will never run until you fix the syntax error.

Now, what does the error mean. Let's analyse it:

syntax error, unexpected T_IS_NOT_EQUAL in /home2/krisindi/public_html/deletead.php on line 4

Bit by bit:

syntax error,

Invalid PHP. The script cannot be executed.

unexpected T_IS_NOT_EQUAL

If has found a T_IS_NOT_EQUAL token. In plain English, it means that is has found a != operator in a place where it was not expected.

in /home2/krisindi/public_html/deletead.php on line 4

This is the exact file and line number where the error was detected. It doesn't mean that the error is there but it's a good place to star. If your editor cannot display line numbers switch to a better editor.

Now, let's look at line 4:

if ( $password ) != 0 )
                 ^
                 T_IS_NOT_EQUAL

Here's the T_IS_NOT_EQUAL token. Why is it unexpected? Because once you've closed the if() construct you have to either open a block with { or type a valid PHP sentence. No valid PHP sentence can start with != thus the error.


@krisdigitx: Line 6

$id = $data->select("Classified", "AdID", array("Password => ($password)));

is missing a "

$id = $data->select("Classified", "AdID", array("Password" => ($password)));
0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜