解析错误:SQL查询语法错误,意外T_String问题

时间:2014-02-16 14:52:49

标签: php sql syntax-error parse-error

我收到此错误:

<br />
<b>Parse error</b>:  syntax error, unexpected 'listings' (T_STRING) in 
<b>C:\xampp\htdocs\android_connect\get_venues.php</b> on line 
<b>30</b>
<br />

这是相应的PHP行:

$result = mysql_query(SELECT * FROM listings WHERE Venue_ID IN (SELECT Venue_ID FROM venues WHERE Venue_Name = $VenueName AND Region = $Region) AND Event_ID IN (SELECT Event_ID FROM events WHERE Event_Name = $VenueName AND Category = $Category);

任何人都可以解决我出错的问题吗?

提前致谢

1 个答案:

答案 0 :(得分:2)

您忘了将字符串换成引号:

$result = mysql_query("SELECT * FROM listings WHERE Venue_ID IN (SELECT Venue_ID FROM venues WHERE Venue_Name = $VenueName AND Region = $Region) AND Event_ID IN (SELECT Event_ID FROM events WHERE Event_Name = $VenueName AND Category = $Category");