Jump to content

Help with sql statement


netman182

Recommended Posts

Can someone help me with this error

 

PHP Parse error: parse error, unexpected T_ENCAPSED_AND_WHITESPACE, expecting T_STRING or T_VARIABLE or T_NUM_STRING

 

the problem line of code is the following:

 

$sql="SELECT players.first, players.last, players.address, players.city, players.postal, players.phone, players.feet, players.inch, players.yyyy, teams.teamname, teams.church, teams.division FROM players, teams WHERE players.teamid = '$_SESSION['teamid']' AND teams.teamid = '$_SESSION['teamid']'";

 

 

what is causing the error?

Link to comment
Share on other sites

When you have a PHP parse error, the line number given is not always the line where the error occurs. It is the line where it can no longer interpret the code in the context given. The line you provided shouldn't cause a PHP error - but it might produce a MySQL error. Post 5-10 lines of code before that line. Most likely you have brackets or quote marks that did not start/end properly. Also, I would change that line above to this:

 

$sql="SELECT players.first, players.last, players.address, players.city,
             players.postal, players.phone, players.feet, players.inch, players.yyyy,
             teams.teamname, teams.church, teams.division
      FROM players, teams
      WHERE players.teamid = '{$_SESSION['teamid']}'
        AND teams.teamid = '{$_SESSION['teamid']}'";

 

Notice th brackets around the variables. I would do that since you have the variables (which have single quotes) enclosed in single quotes as well.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.