I have 2 tables
1 table = files
code | title
luLidwhSl8hmN0T6RsLaDmxAB09UZcX |This is Rar title
4Xwvm1C3yTQJK7CnmxorUDI7sNSvcBK |This is JPG title
…
2 table = hits
page_name | hits
download.php?code=luLidwhSl8hmN0T6RsLaDmxAB09UZcX |102
download.php?code=4Xwvm1C3yTQJK7CnmxorUDI7sNSvcBK |87
…
My Query is :
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>';
}
I get this error
Warning: mysql_fetch_assoc() expects parameter 1 to be resource, boolean given in C:\xampp\htdocs\Edu\filesupload\index.php on line 104
Where is the problem?
Change this:
$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");To this:
$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") or die(mysql_error());Then that should tell you what the error is, because if it was fine, it wouldn’t be returning false.