Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 4 of 4
  1. #1
    New Coder
    Join Date
    Apr 2010
    Posts
    28
    Thanks
    3
    Thanked 0 Times in 0 Posts

    T_IF PHP Parse Error

    I get this: [12-Apr-2012 15:02:17] PHP Parse error: syntax error, unexpected T_IF in /home/sbot/public_html/index.php on line 5

    Here is my code:
    PHP Code:
    <?php

    $password 
    'alex'

    if ($password=='alex'); {
        echo 
    'This is the correct password!';
    }

    ?>
    Line 5 is: if ($password=='alex'); {

  • #2
    New Coder
    Join Date
    Apr 2010
    Posts
    28
    Thanks
    3
    Thanked 0 Times in 0 Posts
    Ahh, Got it

  • #3
    Senior Coder
    Join Date
    Feb 2011
    Location
    Your Monitor
    Posts
    4,091
    Thanks
    51
    Thanked 506 Times in 493 Posts
    Quote Originally Posted by buildblocks View Post
    I get this: [12-Apr-2012 15:02:17] PHP Parse error: syntax error, unexpected T_IF in /home/sbot/public_html/index.php on line 5

    Here is my code:
    PHP Code:
    <?php

    $password 
    'alex'

    if ($password=='alex'); {
        echo 
    'This is the correct password!';
    }

    ?>
    Line 5 is: if ($password=='alex'); {
    You need a ; on the end of your $password line:

    $password = 'alex';
    My helpful sig is on vacation trying to loose some weight. It got a bit fat and caused a few problems but it will be back at some point!

  • #4
    God Emperor Fou-Lu's Avatar
    Join Date
    Sep 2002
    Location
    Saskatoon, Saskatchewan
    Posts
    16,979
    Thanks
    4
    Thanked 2,659 Times in 2,628 Posts
    Yes, but make sure your remove the ; at the end of the if check.
    PHP Code:
    if (false);
    {
        print 
    'I\'m in here.';

    Will print that its in the branch.


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •