MySQL Query gives error: unexpected T_CONSTANT_ENCAPSED_STRING [closed]
I know this error is usually a problem with unclosed quotes and such, but I can't seem to find the problem here. I suspect it's something to do with the parentheses, who knows though.
The error:
Parse error: syntax error, unexpected T_CONSTANT_ENCAPSED_STRING
The query:
$result = @mysql_query('select * from quotes inner join game on game.id=quotes.game_id inner join person on person.id=quotes.speaker_id where game.id = ' . $gameid . ' and person.id in (SELECT person.id
FROM person
JOIN coach ON person.id = coach.person_id
JOIN team ON coach.team_id = team.id where team.id=' . $name '
Union
SELECT person.id
FROM person
JOIN player ON person.id = player.person_id
JOIN team ON player.team_id = team.id where team.id=' . $name . ')');
You write:
' ... JOIN team ON coach.team_id = team.id where team.id=' . $name ' ...
Where it should be:
' ... JOIN team ON coach.team_id = team.id where team.id=' . $name . ' ...
(note the dot right behind $name)
精彩评论