MySQL Query提供错误:意外T_CONSTANT_ENCAPSED_STRING

时间:2011-07-05 19:39:59

标签: php mysql sql

我知道这个错误通常是未关闭的引号等问题,但我似乎无法在这里找到问题。我怀疑它与括号有关,但他知道。

错误:

Parse error: syntax error, unexpected T_CONSTANT_ENCAPSED_STRING 

查询:

$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 . ')');

1 个答案:

答案 0 :(得分:8)

你写道:

' ... JOIN team  ON coach.team_id = team.id where team.id=' . $name ' ...

它应该在哪里:

' ... JOIN team  ON coach.team_id = team.id where team.id=' . $name . ' ...

(注意$ name后面的点)