SitePoint Sponsor

User Tag List

Results 1 to 12 of 12

Thread: syntax error

  1. #1
    SitePoint Enthusiast
    Join Date
    Nov 2007
    Location
    Hull.UK
    Posts
    48
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    syntax error

    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;
    }
    ?>

  2. #2
    SitePoint Wizard lorenw's Avatar
    Join Date
    Feb 2005
    Location
    was rainy Oregon now sunny Florida
    Posts
    1,104
    Mentioned
    2 Post(s)
    Tagged
    0 Thread(s)
    try
    Code:
    WHERE ID ='." mysql_real_escape_string($_GET['ID'])".');
    I think thats correct.
    What I lack in acuracy I make up for in misteaks

  3. #3
    SitePoint Wizard silver trophybronze trophy Cups's Avatar
    Join Date
    Oct 2006
    Location
    France, deep rural.
    Posts
    6,869
    Mentioned
    17 Post(s)
    Tagged
    1 Thread(s)
    PHP Code:
     ... && alpha_numeric ($_GET['key']== TRUE ) ) 
    Missed a closing bracket, I think.

  4. #4
    SitePoint Wizard lorenw's Avatar
    Join Date
    Feb 2005
    Location
    was rainy Oregon now sunny Florida
    Posts
    1,104
    Mentioned
    2 Post(s)
    Tagged
    0 Thread(s)
    Actually I think he had it in the code but the comment ate it up

    //20 line is coming here// {
    What I lack in acuracy I make up for in misteaks

  5. #5
    From space with love silver trophy
    SpacePhoenix's Avatar
    Join Date
    May 2007
    Location
    Poole, UK
    Posts
    5,077
    Mentioned
    103 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by lorenw View Post
    Actually I think he had it in the code but the comment ate it up

    //20 line is coming here// {
    I think that's the line that's giving the trouble, it's a stray {
    Community Team Advisor
    Forum Guidelines: Posting FAQ Signatures FAQ Self Promotion FAQ
    Help the Mods: What's Fluff? Report Fluff/Spam to a Moderator

  6. #6
    SitePoint Wizard lorenw's Avatar
    Join Date
    Feb 2005
    Location
    was rainy Oregon now sunny Florida
    Posts
    1,104
    Mentioned
    2 Post(s)
    Tagged
    0 Thread(s)
    The concatenation is all wrong here,

    Code:
    ='" mysql_real_escape_string($_GET['ID'])."'
    change to
    Code:
    ='".mysql_real_escape_string($_GET['ID'])."'
    My first post was wrong, I am just disracted today. Merry Christmas.
    What I lack in acuracy I make up for in misteaks

  7. #7
    SitePoint Enthusiast
    Join Date
    Nov 2007
    Location
    Hull.UK
    Posts
    48
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by lorenw View Post
    The concatenation is all wrong here,

    Code:
    ='" mysql_real_escape_string($_GET['ID'])."'
    change to
    Code:
    ='".mysql_real_escape_string($_GET['ID'])."'
    My first post was wrong, I am just disracted today. Merry Christmas.
    -------------
    lorenw

    Thanks thats workes .

  8. #8
    SitePoint Wizard PHPycho's Avatar
    Join Date
    Dec 2005
    Posts
    1,201
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Such type of syntax errors can get easily get off while coding by using some strong PHP editors like:Zend Eclipse.
    Thanks

  9. #9
    SitePoint Wizard PHPycho's Avatar
    Join Date
    Dec 2005
    Posts
    1,201
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Such type of syntax errors can get easily get off while coding by using some strong PHP editors like:Zend Eclipse.
    Thanks

  10. #10
    SitePoint Evangelist Dave Morton's Avatar
    Join Date
    Sep 2003
    Location
    Carson City, NV
    Posts
    557
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Off Topic:

    I just downloaded Eclipse for PHP, but haven't installed it yet. I'm wondering how well it works, compared to, say, WeBuilder 2k8...
    Making a difference, one little psychotic episode at a time
    Geek Cave Creations
    Beta testers needed for pChat
    Dave's Gallery

  11. #11
    SitePoint Addict
    Join Date
    Jul 2008
    Posts
    220
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)
    u can use some free powerful PHP Editors that will perform syntax coloring and syntax checking.

    one of my favorite is Komodo Edit, free download from http://www.activestate.com/komodo_edit/

  12. #12
    SitePoint Evangelist Dave Morton's Avatar
    Join Date
    Sep 2003
    Location
    Carson City, NV
    Posts
    557
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    WeBuilder has all that, including an internal PHP interpreter, to allow for other nice features in addition to syntax checking. I'm interested in Eclipse because I hear it has more detailed debugging capabilities, which will allow me to use fewer file saving routines within my code (I use them to capture certain data during runtime, so I can see what's going on with my scripts - sort of "hillbilly debugging", as it were).
    Making a difference, one little psychotic episode at a time
    Geek Cave Creations
    Beta testers needed for pChat
    Dave's Gallery


Bookmarks

Posting Permissions

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