Php Error T_IF

Discussion in 'PHP' started by Stoove, Jul 30, 2008.

  1. #1
    Here is my code and on line 3, it says their is an unexpected T_IF error:
    <?php
    $pass = $_POST ['pass']
    if ($pass == 'Pivet');{
    echo 'Header("Location:http://www.new-site.com");'"
    }
    else {
    echo 'InCorrect Password;
    }
    ?>
    Code (markup):
    Please tell me what is wrong
     
    Stoove, Jul 30, 2008 IP
  2. Pos1tron

    Pos1tron Peon

    Messages:
    95
    Likes Received:
    7
    Best Answers:
    0
    Trophy Points:
    0
    #2
    <?php
    $pass = $_POST ['pass'] [B]<< remove the space between $_POST and ['pass'] here[/B]
    if ($pass == 'Pivet')[B];[/B]{ [B]<< remove the semicolon here, this was causing the error - semicolon's don't go there[/B]
    echo 'Header("Location:http://www.new-site.com");'[B]"[/B] [B]<< remove the " and entire echo statement here and move the semicolon to the end of the line, this would have later caused an error - headers are outputted by the Header function, echo is unnecessary (and may have caused an error)[/B]
    }
    else {
    echo 'InCorrect Password; [B]<< add an ' after the Password and before the semicolon, this would have later caused an error[/B]
    }
    ?>
    Code (markup):
    This code below is the code you want, read the code above for information on what I did.
    <?php
    $pass = $_POST['pass']
    if ($pass == 'Pivet') {
    Header("Location:http://www.new-site.com");
    }
    else {
    echo 'InCorrect Password';
    }
    ?>
    Code (markup):
     
    Pos1tron, Jul 30, 2008 IP
  3. TwistMyArm

    TwistMyArm Peon

    Messages:
    931
    Likes Received:
    44
    Best Answers:
    0
    Trophy Points:
    0
    #3
    Well... the actual error is probably coming from the lack of a semi-colon at the end of the:
    $pass = $_POST['pass']

    but yeah, the rest is all necessary, too... no offense, but that code snippet probably has the highest errors / line I've ever seen...
     
    TwistMyArm, Jul 30, 2008 IP
  4. Pos1tron

    Pos1tron Peon

    Messages:
    95
    Likes Received:
    7
    Best Answers:
    0
    Trophy Points:
    0
    #4
    Indeed. I noticed two at first. Then three, then 4. Now you've pointed out a fifth...
     
    Pos1tron, Jul 30, 2008 IP
  5. Stoove

    Stoove Peon

    Messages:
    116
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #5
    Ya its my first time with php, im just trying to learn a little.
     
    Stoove, Jul 30, 2008 IP