導致我有2個表mysql的2臺,獲得從2個表
1表=文件
code | title
luLidwhSl8hmN0T6RsLaDmxAB09UZcX |這是的RAR標題
4Xwvm1C3yTQJK7CnmxorUDI7sNSvcBK |這是JPG標題
...
2表=匹配
page_name | hits
的download.php碼= luLidwhSl8hmN0T6RsLaDmxAB09UZcX | 102
的download.php碼= 4Xwvm1C3yTQJK7CnmxorUDI7sNSvcBK | 87
...
我的查詢是:??
include('db.inc.php');
$query = mysql_query("SELECT t1.code, t1.title, RIGHT(t2.page_name, 31) as t2.page_name, t2.hits FROM files t1 INNER JOIN hits t2 ON t1.code= RIGHT(t2.page_name, 31) as t2.page_name ORDER by t2.hits DESC LIMIT 1, 7");
while ($result = mysql_fetch_assoc($query)) {
echo ' <div id="linkstyle"><strong><a href="http://localhost/edu/filesupload/download.php?code='. $result['t1.code'] . ' ">' , $result['t1.title'] , '</a></strong><br></div>';
}
我收到此錯誤
Warning: mysql_fetch_assoc() expects parameter 1 to be resource, boolean given in C:\xampp\htdocs\Edu\filesupload\index.php on line 104
問題在哪裏?
我的錯誤是:您的SQL語法錯誤;檢查與您的MySQL服務器版本相對應的手冊,以便在'.page_name,t2.hits FROM files t1 INNER JOIN命中t2 ON t1.code = RIGHT(t2.page_n'在第1行處使用' – user1929805
'附近使用的正確語法。這就是答案:$ query = mysql_query(「SELECT t1.code,t1.title,RIGHT(t2.page_name,31),t2.hits FROM files t1 INNER JOIN hits t2 ON t1.code = RIGHT(t2.page_name,31)ORDER by t2.hits DESC LIMIT 1,7「); – user1929805
感謝您的支持 – user1929805