syntax error

Discussion in 'PHP' started by vivek42, Dec 27, 2009.

  1. #1
    Hi Guys

    i am receiving this message .

    Parse error: syntax error, unexpected '{' in /home/mardan/public_html/login/confirm.php on line 20

    -------------
    could you check my code , i have no idea why this given me.

    Thanks

    <?php
    require_once('db.php');
    include('function');

    if($_GET['ID']!= '' && numeric ($_GET['ID']) == TRUE && strlen ($_GET['key'])== 32 && alpha_numeric ($_GET['key']== TRUE )

    //20 line is coming here// {

    $query = mysql_query("SELECT ID,Random_key,Active FROM users WHERE ID ='" mysql_real_escape_string($_GET['ID'])."'");

    if(mysql_num_rows($query)==1)
    {
    $row=mysql_fetch_assoc($query);

    if($row['Active']==1)
    {
    $error='This member is already active !';
    }
    elseif($row['Random_key']!=$_GET['key'])
    {
    $error='The Confirmation key that was generated for this member does not match with our entered ';
    }
    else
    {
    $update =mysql_query("UPDATE users SET Active=1 WHERE ID ='".mysql_real_escape_string($row['ID'])."'") or die (mysql_error());

    $msg = 'Congratulations ! You just confirmed your membership </br>
    <p>This script automatically redirects to Login page.</p></br>
    <p>If you are not redirected to another page within 15 seconds, then please <a href="http://www.mardan.org.uk/login">click here</a>.</p>! ';
    }
    }
    else {

    $error = 'User not found !';

    }

    }
    else {

    $error = 'Invalid data provided !';

    }

    if(isset($error))
    {
    echo $error;
    }
    else {
    echo $msg;
    }
    ?>


    reply must
     
    vivek42, Dec 27, 2009 IP
  2. CoreyPeerFly

    CoreyPeerFly Notable Member Affiliate Manager

    Messages:
    394
    Likes Received:
    24
    Best Answers:
    5
    Trophy Points:
    240
    #2
    if($_GET['ID']!= '' && numeric ($_GET['ID']) == TRUE && strlen ($_GET['key'])== 32 && alpha_numeric ($_GET['key']== TRUE )
    PHP:
    should be
    if(!empty($_GET['ID']) && numeric($_GET['ID']) == TRUE && strlen($_GET['key']) == 32 && alpha_numeric($_GET['key'] == TRUE))
    PHP:
    and

    $query = mysql_query("SELECT ID,Random_key,Active FROM users WHERE ID ='" mysql_real_escape_string($_GET['ID'])."'");
    PHP:
    should be
    $query = mysql_query("SELECT `ID`, `Random_key`, `Active` FROM `users` WHERE `ID` = '" . mysql_real_escape_string($_GET['ID']) . "'");
    PHP:
     
    Last edited: Dec 27, 2009
    CoreyPeerFly, Dec 27, 2009 IP
  3. w3goodies

    w3goodies Member

    Messages:
    94
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    38
    #3
    Here is the fixed Code:
    
    <?php
    
    if($_GET['ID']!= '' && numeric ($_GET['ID']) == TRUE && strlen($_GET['key'])== 32 && alpha_numeric($_GET['key'])== TRUE){
    //20 line is coming here//
    $query = mysql_query("SELECT ID,Random_key,Active FROM users WHERE ID ='". mysql_real_escape_string($_GET['ID']).".'");
    
    if(mysql_num_rows($query)==1)
    {
    $row=mysql_fetch_assoc($query);
    
    if($row['Active']==1)
    {
    $error='This member is already active !';
    }
    elseif($row['Random_key']!=$_GET['key'])
    {
    $error='The Confirmation key that was generated for this member does not match with our entered ';
    }
    else
    {
    $update =mysql_query("UPDATE users SET Active=1 WHERE ID ='".mysql_real_escape_string($row['ID'])."'") or die (mysql_error());
    
    $msg = 'Congratulations ! You just confirmed your membership </br>
    <p>This script automatically redirects to Login page.</p></br>
    <p>If you are not redirected to another page within 15 seconds, then please <a href="http://www.mardan.org.uk/login">click here</a>.</p>! ';
    }
    }
    else {
    
    $error = 'User not found !';
    
    }
    
    }
    else {
    
    $error = 'Invalid data provided !';
    
    }
    
    if(isset($error))
    {
    echo $error;
    }
    else {
    echo $msg;
    }
    ?>
    PHP:
     
    w3goodies, Dec 28, 2009 IP