pacitto513 Posted May 23, 2012 Share Posted May 23, 2012 Hey everyone, I have this php code below and for some reason I keep getting the following error message when my page is loaded: Warning: mysql_fetch_array() expects parameter 1 to be resource, boolean given in C:\xampp\htdocs\Website-v1.0\root\home.php on line 47 Iv tried changing a few things within my code but nothing seems to work. Any ideas on how to fix this bug? <?php $post_user_pic= ''; $postDisplayList = ''; $deletepost= ''; $sql_posts_data = mysql_query("SELECT postid, member_id, location, post_body, post_date, replies FROM posts ORDER BY post_date DESC LIMIT 10"); while($row = mysql_fetch_array($sql_posts_data)){ $postid = $row["postid"]; $postuserid = $row["member_id"]; $post_body= $row["post_body"]; $location = $row["location"]; $postreplies = $row["replies"]; $post_date = $row["post_date"]; $post_date = strftime("%b %d, %Y at %I:%M %p", strtotime($post_date)); $sql_postmem_data = mysql_query("SELECT id, username, fullname FROM members WHERE id='$postuserid' LIMIT 1"); while($row = mysql_fetch_array($sql_postmem_data)){ $postmemberid = $row["id"]; $postusername = $row["username"]; $postfullname = $row["fullname"]; $post_user_check_pic = "members/$postmemberid/image01.jpg"; $post_user_default_pic = "members/0/defaultpic.jpg"; if (file_exists($post_user_check_pic)) { $post_user_pic = "<img src=\"$post_user_check_pic\" width=\"50px\" height=\"50px\" ?BORDER=\"0\" border=\"0\" />"; } else { $post_user_pic = "<img src=\"$post_user_default_pic\" width=\"50px\" height=\"50px\" ?BORDER=\"0\" border=\"0\" />"; } if (isset($_SESSION['id'])) { if($_SESSION['id']==$uid){ $postDisplayList .= ''; } else $postDisplayList .= ''; } } } ?> Quote Link to comment Share on other sites More sharing options...
Jessica Posted May 23, 2012 Share Posted May 23, 2012 It means your query failed, you need to be checking for errors with mysql_error() before trying to use the result of a query. Quote Link to comment Share on other sites More sharing options...
DanWhite Posted May 27, 2012 Share Posted May 27, 2012 Is there anything in your database? or are you just expecting the PHP to return nothing? Quote Link to comment Share on other sites More sharing options...
.josh Posted May 27, 2012 Share Posted May 27, 2012 I see nowhere in your script where you actually connect and select a database...you should have a mysql_connect and mysql_select_db in there before your query. Did you not post that part of the script, or do you really not have that in your script? Quote Link to comment 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.