我一直在把头发拉过来,我希望这里有人可以提供帮助。任何帮助将不胜感激。
我在本地64位Win 7平台上使用WAMP,而WAMP打包的MySQL版本是5.0.1a。我还将smf嵌入到Wordpress模板中。接下来是header.php文件中的代码,以及特定错误:
“您的SQL语法有错误;请查看与您的MySQL服务器版本对应的手册,以便在第7行'AND xxxx.xxxx_members.ID_MEMBER ='附近使用正确的语法”
<?php
// Get race image
$members = xxxx_FORUM_MEMBERS_TABLE;
$forum_id = xxxx_forum_user_id();
$sql = "SELECT users.race, {$members}.memberName, ranks.rank
FROM
{$members}, users
LEFT JOIN ranks
ON users.id = ranks.user_id
WHERE users.forum_id = {$forum_id}
AND {$members}.ID_MEMBER = {$forum_id}";
$users = mysql_query($sql) or die (mysql_error());
$race = "unknown";
$name = "";
$rank = null;
if ($user = mysql_fetch_object($users)) {
$race = $user->race;
$name = $user->memberName;
$rank = $user->rank;
if ($rank != null) {
// Prefix 1th, 2nd 3rd, 4th
$order = $rank % 10;
if ($rank > 10 || $rank < 21) $rank .= 'th';
else if ($order == 1) $rank .= 'th';
else if ($order == 2) $rank .= 'nd';
else if ($order == 3) $rank .= 'rd';
else $rank .= 'th';
}
}
?>
答案 0 :(得分:0)
鉴于您的错误:
您的SQL语法有错误;检查与MySQL服务器版本对应的手册,以便在第7行的'AND xxxx.xxxx_members.ID_MEMBER ='附近使用正确的语法
您似乎正在选择db.table
。您应该尝试以下语法:
SELECT tbl1.col1
FROM db.tbl1
WHERE tbl1.col1 ...
而不是:
SELECT tbl1.col1
FROM db.tbl1
WHERE db.tbl1.col1 ...