Reputation: 81841
if ((isset($post["username"]) && isset($post["password"])) && (!empty($post["username"]) && !empty($post["password"])) && ($post["username"] == "something" && $post["password"] == "something"))
{
}
Error: syntax error, unexpected T_IF in [file_name here but I rather not expose the file path and name]
I know it is kinda complicated but what's wrong with this if-statement as I receive the error above. Although I checked several times.
Upvotes: 0
Views: 84
Reputation: 32290
Another suggestion I might make (for the sake of other people who might have to edit your code later) is to break down the if statement:
$valuesAreSet = isset($post["username"]) && isset($post["password"]);
$areNotEmpty = !empty($post["username"]) && !empty($post["password"]);
$areValid = $post["username"] == "something" && $post["password"] == "something";
if ($areSet && $areNotEmpty && $areValid) {
...
}
Upvotes: 2
Reputation: 10646
Make sure you aren't missing any semi-colons.
Also just to check, you did want to use the variable $post
and not $_POST
right?
Upvotes: 1
Reputation: 1239
That error unexpected T_IF
indicates that the if is unexpected, meaning there is an error BEFORE the if. Probably a dropped semicolon. Check above the if and you should find your problem.
Upvotes: 2
Reputation: 71939
You're probably missing a semicolon in the line that precedes the if
.
Upvotes: 1