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
谢谢肖恩,就是这样! –