What am I doing wrong here? (IF blocks)

Discussion in 'PHP' started by easydolla, Apr 3, 2009.

  1. #1
    Im making a simple "age verification" page, using $_GET & IF

    but I am getting a syntax error; "Parse error: syntax error, unexpected T_IF in /home/.../public_html/verifyage.php on line 12"

    I am a virgin to PHP and don't know what that error means

    here is the code:

    <html>
    <head><title>$GET Test</title></head>
    <body>
    <form action="verifyage.php" method="get">
    Name:<input type="text" name="name" />
    Age:<input type="text" name="age" />
    <input type="submit" />
    </form>
    <br>
    <?php
    $age = $_GET["age"]
    if ($age < 18)
    {
    echo "You are not old enough to enter this site.";
    }
    ?>
    </body>
    </html>
    PHP:

     
    easydolla, Apr 3, 2009 IP
  2. ActiveFrost

    ActiveFrost Notable Member

    Messages:
    2,072
    Likes Received:
    63
    Best Answers:
    3
    Trophy Points:
    245
    #2
    You need to add ; at the end of each statement ( in this case, variable definition and if block are two separate statements ) :
    <html>
    <head><title>$GET Test</title></head>
    <body>
    <form action="verifyage.php" method="get">
    Name:<input type="text" name="name" />
    Age:<input type="text" name="age" />
    <input type="submit" />
    </form>
    <br>
    <?php
    $age = $_GET["age"];
    if ($age < 18)
    {
    echo "You are not old enough to enter this site.";
    }
    ?>
    </body>
    </html>
    PHP:
     
    ActiveFrost, Apr 3, 2009 IP
  3. easydolla

    easydolla Peon

    Messages:
    403
    Likes Received:
    5
    Best Answers:
    0
    Trophy Points:
    0
    #3
    Wow, Im such an idiot.

    Its always something small
     
    easydolla, Apr 3, 2009 IP
  4. kusal

    kusal Peon

    Messages:
    91
    Likes Received:
    3
    Best Answers:
    0
    Trophy Points:
    0
    #4
    don't worry once you get use to error messages you will instantly find the error.
     
    kusal, Apr 3, 2009 IP