SitePoint Sponsor

User Tag List

Results 1 to 7 of 7
  1. #1
    SitePoint Wizard
    Join Date
    Jul 2006
    Location
    New Zealand
    Posts
    1,300
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Parse error: syntax error, unexpected T_ENCAPSED_AND_WHITESPACE, expecting T_STRING o

    Hi all,

    I am having a problem with my php code for some reason i am getting this error and i cant find the problem.

    heres the error message

    Parse error: syntax error, unexpected T_ENCAPSED_AND_WHITESPACE, expecting T_STRING or T_VARIABLE or T_NUM_STRING in C:\Program Files\xampp\htdocs\StickmenStudios\internships\Project1\test.php on line 22

    The Php code is

    PHP Code:
    include("dbconnect.php");
    `
                    $d="SELECT * FROM players WHERE pid='$pid'";
                    echo 
    $d;
                    
    $rs=mysqli_query($con,$d);
                    if(!
    $rs)
                    {
                        echo "Cant Attack User because of: ".mysqli_error(
    $con);
                    }
                    else
                    {
                        //
                        
    $count=$rs->num_rows;
                        if(
    $count>0)
                        {
                            while(
    $data=mysqli_fetc_assoc($rs))
                            {
                                
    $p=$data['units'];
                                
    $n=$data['user'];    
                            }
                            userlogininfo(
    $f,$n,$p);
                        }
                        else
                        {
                            echo "Cant find player information";
                        }
                        //    
                    } 
    Not sure what is causing this error as it seems fine for me. can anyone tell me what is causing this problem?

    Thanks,William

  2. #2
    SitePoint Enthusiast
    Join Date
    Nov 2009
    Posts
    70
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    PHP Code:
    include("dbconnect.php"); 
    ` <----- there is a (prime ′ ) character which cause this error

  3. #3
    SitePoint Wizard
    Join Date
    Jul 2006
    Location
    New Zealand
    Posts
    1,300
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    hmm ive just checked and they " not ''

    PHP Code:

    include("dbconnect.php");
    `
                    $d="SELECT * FROM players WHERE pid='$pid'";
                    echo 
    $d;
                    
    $rs=mysqli_query($con,$d);
                    if(!
    $rs)
                    {
                        echo "Cant Attack User because of:&nbsp;".mysqli_error(
    $con);
                    }
                    else
                    {
                        //
                        
    $count=$rs->num_rows;
                        if(
    $count>0)
                        {
                            while(
    $data=mysqli_fetc_assoc($rs))
                            {
                                
    $p=$data['units'];
                                
    $n=$data['user'];    
                            }
                            userlogininfo(
    $f,$n,$p);
                        }
                        else
                        {
                            echo "Cant find player information";
                        }
                        //    
                    } 

  4. #4
    SitePoint Enthusiast
    Join Date
    Nov 2009
    Posts
    70
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    in this line:
    PHP Code:
    $d="SELECT * FROM players WHERE pid='$pid'"
    at the very beginning, there is a prime character (`) see that closer...

  5. #5
    SitePoint Enthusiast
    Join Date
    Nov 2009
    Posts
    70
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    see my screenshot in the attachement.
    Attached Images Attached Images

  6. #6
    Unobtrusively zen silver trophybronze trophy
    paul_wilkins's Avatar
    Join Date
    Jan 2007
    Location
    Christchurch, New Zealand
    Posts
    14,729
    Mentioned
    104 Post(s)
    Tagged
    4 Thread(s)
    This feels like a pantomine (he's behiiiiiinnnddd yooouuuuu!!)

    Quote Originally Posted by william232 View Post
    PHP Code:
    include("dbconnect.php");
    `
                    $d="SELECT * FROM players WHERE id='$pid'"; 

    Let me show that again:

    Code:
    `                $d="SELECT * FROM players WHERE id='$pid'"; 
    
    ^
    |
    `---- On the far left there.
    Programming Group Advisor
    Reference: JavaScript, Quirksmode Validate: HTML Validation, JSLint
    Car is to Carpet as Java is to JavaScript

  7. #7
    I solve practical problems. bronze trophy
    Michael Morris's Avatar
    Join Date
    Jan 2008
    Location
    Knoxville TN
    Posts
    2,053
    Mentioned
    66 Post(s)
    Tagged
    1 Thread(s)
    Get a color-context editor - it makes mistakes like this very obvious. Note how the one built into PHP changes the colors of the text when the offending ` character is removed:

    BEFORE:
    PHP Code:
    include("dbconnect.php");
    `
                    $d="SELECT * FROM players WHERE pid='$pid'";
                    echo 
    $d;
                    
    $rs=mysqli_query($con,$d);
                    if(!
    $rs)
                    {
                        echo "Cant Attack User because of:&nbsp;".mysqli_error(
    $con);
                    }
                    else
                    {
                        //
                        
    $count=$rs->num_rows;
                        if(
    $count>0)
                        {
                            while(
    $data=mysqli_fetc_assoc($rs))
                            {
                                
    $p=$data['units'];
                                
    $n=$data['user'];    
                            }
                            userlogininfo(
    $f,$n,$p);
                        }
                        else
                        {
                            echo "Cant find player information";
                        }
                        //    
                    } 
    AFTER:
    PHP Code:
    include("dbconnect.php");
                    
    $d="SELECT * FROM players WHERE pid='$pid'";
                    echo 
    $d;
                    
    $rs=mysqli_query($con,$d);
                    if(!
    $rs)
                    {
                        echo 
    "Cant Attack User because of:&nbsp;".mysqli_error($con);
                    }
                    else
                    {
                        
    //
                        
    $count=$rs->num_rows;
                        if(
    $count>0)
                        {
                            while(
    $data=mysqli_fetc_assoc($rs))
                            {
                                
    $p=$data['units'];
                                
    $n=$data['user'];    
                            }
                            
    userlogininfo($f,$n,$p);
                        }
                        else
                        {
                            echo 
    "Cant find player information";
                        }
                        
    //    
                    

    Notepad++ is one of the better ones out there for windows, jEdit is also quite powerful. Both of these options are free.


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
  •