zero_ZX Posted August 27, 2011 Share Posted August 27, 2011 Hi, So maybe some fresh eyes can tell me what's wrong <?PHP //Get and display news $result = mysql_query("SELECT * FROM groups_news WHERE group = ('$getid') AND topic = 0 ORDER BY date DESC"); IF (!result) { die(mysql_error()); } while($row = mysql_fetch_array($result)) { $topicid = $row["id"]; $authorid = $row["author"]; //Get profile info from author $result2 = mysql_query("SELECT * FROM profiles WHERE id=('$authorid') LIMIT 1"); IF (!result2) { die(mysql_error()) +"Result 2"; } $row2 = mysql_fetch_array($result2); //Count comments $result3 = mysql_query("SELECT * FROM groups_news WHERE group=('$getid') AND topic=1"); IF (!result3) { die(mysql_error()+"Result 3"); } Returns the usual: Warning: mysql_fetch_array() expects parameter 1 to be resource, boolean given in C:\xampp\htdocs\prog\groups.php on line 38 Line 38: while($row = mysql_fetch_array($result)) Any help is much appreciated. Quote Link to comment https://forums.phpfreaks.com/topic/245832-help-with-a-query/ Share on other sites More sharing options...
cunoodle2 Posted August 27, 2011 Share Posted August 27, 2011 Are there more lines of code? Are you sure that is the line 38? I see these.. IF (!result) SHOULD be.. IF (!$result) (note they are ALL like that) Quote Link to comment https://forums.phpfreaks.com/topic/245832-help-with-a-query/#findComment-1262657 Share on other sites More sharing options...
Pikachu2000 Posted August 27, 2011 Share Posted August 27, 2011 That error indicates the query failed and is returning a boolean FALSE instead of a result resource. Are you getting anything returned form mysql_error()? <-- nevermind for the moment, you won't get an error until you fix the problem pointed out by cunoodle2 Quote Link to comment https://forums.phpfreaks.com/topic/245832-help-with-a-query/#findComment-1262659 Share on other sites More sharing options...
zero_ZX Posted August 27, 2011 Author Share Posted August 27, 2011 Are there more lines of code? Are you sure that is the line 38? I see these.. IF (!result) SHOULD be.. IF (!$result) (note they are ALL like that) fail lol Okay so got this: 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 'group = ('1') AND topic = 0 ORDER BY date DESC' at line 1 Will i have to escape date? Quote Link to comment https://forums.phpfreaks.com/topic/245832-help-with-a-query/#findComment-1262661 Share on other sites More sharing options...
Pikachu2000 Posted August 27, 2011 Share Posted August 27, 2011 GROUP is a MySQL reserved word. Quote Link to comment https://forums.phpfreaks.com/topic/245832-help-with-a-query/#findComment-1262664 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.