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
https://forums.phpfreaks.com/topic/192093-help-with-sql-statement/
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.

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.