liamoco Posted December 8, 2010 Share Posted December 8, 2010 This is the error is am getting Warning: mysql_fetch_assoc() expects parameter 1 to be resource, boolean given in C:\server\xampp\htdocs\php\home\chats\home-chats.php on line 58 And this is the query $popularToday_query = mysql_query("SELECT round(avg(likes)) + round(avg(favourites)) as rating, chat_name FROM chat_likes GROUP BY chat_name WHERE timeRated >= ".$curTime." ORDER BY rating DESC LIMIT 4"); I have triple checked that I have all the field names correct, what am I doing wrong? Thanks Quote Link to comment https://forums.phpfreaks.com/topic/221051-query-error/ Share on other sites More sharing options...
PFMaBiSmAd Posted December 8, 2010 Share Posted December 8, 2010 You can echo mysql_error(); to find out why the query is failing. Quote Link to comment https://forums.phpfreaks.com/topic/221051-query-error/#findComment-1144580 Share on other sites More sharing options...
liamoco Posted December 8, 2010 Author Share Posted December 8, 2010 You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'WHERE timeRated >= 1291833493 ORDER BY rating DESC ' at line 4 Quote Link to comment https://forums.phpfreaks.com/topic/221051-query-error/#findComment-1144589 Share on other sites More sharing options...
Maq Posted December 8, 2010 Share Posted December 8, 2010 I believe GROUP BY should come right after your WHERE clause. Quote Link to comment https://forums.phpfreaks.com/topic/221051-query-error/#findComment-1144591 Share on other sites More sharing options...
liamoco Posted December 8, 2010 Author Share Posted December 8, 2010 Cheers Guys Quote Link to comment https://forums.phpfreaks.com/topic/221051-query-error/#findComment-1144593 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.