0
由於我的服務提供商不再支持舊版本,我不得不更新到MySQL 5和PHP 5。我有一個工作網站,這個MySQL搜索工作正常。以下是放置在用戶的列表頁面上的一個包含。當我將SQL語句取出並在服務器上運行時,它會返回正確的結果。我的猜測是這與格式有關。任何想法,爲什麼我可能會得到這個錯誤? 「查詢失敗:您的SQL語法出錯;檢查與您的MySQL相對應的手冊
」查詢失敗:您的SQL語法有錯誤;請查看與您的MySQL服務器版本相對應的手冊,以便在第1行「ORDER BY x.id_have LIMIT 0,30'附近使用正確的語法」
有了這個語法
<table cellpadding="15" border="0">
<tr>
<td valign="top">
So far, the following members have these items which match;
<ul>
<?
$peoplewhomatch = mysql_query("SELECT x.id_customer, g.title Have, c.user_name as Member, g.title gwants, gg.title Has, y.id_customer x_username
FROM Want x
JOIN Want y
ON (y.id_sellversion,y.id_version) = (x.id_version,x.id_sellversion)
inner join Version as v
on x.id_version = v.id_version
inner join Version as vv
on y.id_version = vv.id_version
inner join Game as g
on g.id_game = vv.id_game
inner join Customer as c
on y.id_customer = c.id_customer
inner join Game as gg
on gg.id_game = v.id_game
WHERE x.id_have = $hid
ORDER BY x.id_have
LIMIT 0, 30")or die("Query failed: " . mysql_error());
while($row = mysql_fetch_array($peoplewhomatch))
{ ?>
<span class='greenitalic'><?=$row['Member']?></span> has <span class='highshadow'><?=$row['Has']?></span> and wants <span class='ishadow'><?=$row['gwants']?></span><BR><?}?>
</td>
</tr>
</table>
'... WHERE x.id_have = '$藏' ORDER BY ...'?如果'$ hid'是一個字符串,需要用單引號包裝 - ''$ hid'' – Sean
謝謝肖恩,就是這樣! –