chrismcf Posted July 7, 2012 Share Posted July 7, 2012 ok so im new to this forum and new to posting in forums altogether so if i dont do this right please let me know what im doing wrong so i can correct myself. so i am having a few problems with my code and really strugleing to get it going right. the first issue i am having is stated in the title of this post: mysql_fetch_array() expects parameter 1 to be resource, boolean given i would be very greatful if i could get help with these issues, there are four of them but im sure all four are simple. ill try to tackle them one at a time though. $MemberDisplayList = '<table border="0" align="center" cellpadding="6"> <tr> '; // Mysql connection is already made in the file this one gets included into // So we can run queries here without having to connect again $sql = mysql_query("SELECT id, username, firstname FROM myMembers Where email_activated='1' ORDER BY RAND() LIMIT 9"); while($row = mysql_fetch_array($sql)){ $id = $row["id"]; $username = $row["username"]; $firstname = $row["firstname"]; if (!$firstname) { $firstname = $username; } $firstnameCut = substr($firstname, 0, 10); $check_pic = "members/$id/image01.jpg"; if (file_exists($check_pic)) { $user_pic = "<img src=\"members/$id/image01.jpg\" width=\"64px\" border=\"0\" />"; } else { $user_pic = "<img src=\"members/0/image01.jpg\" width=\"64px\" border=\"0\" />"; } $MemberDisplayList .= '<td><a href="profile.php?id=' . $id . '" title="' . $firstname . '"><font size="-2">' . $firstnameCut . '</font></a><br /> <div style=" height:64px; overflow:hidden;"><a href="profile.php?id=' . $id . '" title="' . $firstname . '">' . $user_pic . '</a></div></td>'; } // close while loop $MemberDisplayList .= ' </tr> </table> '; ?> Quote Link to comment https://forums.phpfreaks.com/topic/265336-mysql_fetch_array-expects-parameter-1-to-be-resource-boolean-given/ Share on other sites More sharing options...
xyph Posted July 7, 2012 Share Posted July 7, 2012 Your query is returning FALSE. That means there's an error in your query. Quote Link to comment https://forums.phpfreaks.com/topic/265336-mysql_fetch_array-expects-parameter-1-to-be-resource-boolean-given/#findComment-1359800 Share on other sites More sharing options...
chrismcf Posted July 7, 2012 Author Share Posted July 7, 2012 could i get you to correct the coding of my query so it works right and i can see where the mistake was? Quote Link to comment https://forums.phpfreaks.com/topic/265336-mysql_fetch_array-expects-parameter-1-to-be-resource-boolean-given/#findComment-1359803 Share on other sites More sharing options...
jcbones Posted July 7, 2012 Share Posted July 7, 2012 Sure: $sql = mysql_query("SELECT id, username, firstname FROM myMembers Where email_activated='1' ORDER BY RAND() LIMIT 9") or trigger_error(mysql_error()); Quote Link to comment https://forums.phpfreaks.com/topic/265336-mysql_fetch_array-expects-parameter-1-to-be-resource-boolean-given/#findComment-1359816 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.