Search code examples
phpparse-errorcontrol-structure

Why am I getting this parse error in a PHP if statement?


I am getting this error:

Parse error: syntax error, unexpected '!=' (T_IS_NOT_EQUAL) in C:\xampp\htdocs\assurance\confirmation.php on line 131

Here is lines 131-134 of my code:

if ($_POST['password']) != ($_POST['confirm'])  { 
echo '<p class="error">Your passwords do not match.</p>';
$okay = FALSE;
}

Solution

  • if ($_POST['password'] != $_POST['confirm'])  { 
    echo '<p class="error">Your passwords do not match.</p>';
    $okay = FALSE;
    }
    

    the syntax of the if statement is

    if (expr)
      statement
    

    See http://www.php.net/manual/en/control-structures.if.php