TottoBennington Posted January 16, 2012 Share Posted January 16, 2012 HELP ME TO CHANGE THE ERROR <?PHP //Include connection to database include('connect.php'); //Get posted values from form $status=$_POST['status']; $date=$_POST['date']; //Strip slashes $status = stripslashes($status); $date = stripslashes($date); //Strip tags $status = strip_tags($status); $date = strip_tags($date); //Inset into database $insert_status = mysql_query(" insert into status (status) value ('$status')") or die (mysql_error()); $insert_status = mysql_query("insert into status (date) value ('$date')") or die (mysql_error()); while($row = mysql_fetch_array($insert_status)) { (ERROR IS IN THIS LINE) $status=$row['status']; $date=$row['date']; } //Line break after every 80 $status = wordwrap($status, 80, "\n", true); //Line breaks $status=nl2br($status); //Display status from data base echo '<div class="load_status"> <div class="status_img"><img src="blankSilhouette.png" /></div> <div class="status_text"><a href="#" class="blue">Anonimo</a><p class="text">'.$status.'</p> <div class="date">'.$date.' · <a href="#" class="light_blue">Like</a> · <a href="#" class="light_blue">Comment</a></div> </div> <div class="clear"></div> </div>'; ?> Link to comment https://forums.phpfreaks.com/topic/255145-warning-mysql_fetch_array-expects-parameter-1-to-be-resource-boolean-given-in/ Share on other sites More sharing options...
scootstah Posted January 16, 2012 Share Posted January 16, 2012 It's because the query failed, so $insert_status is false. Your query needs to be insert into ... values ... instead of insert into ... value ... Link to comment https://forums.phpfreaks.com/topic/255145-warning-mysql_fetch_array-expects-parameter-1-to-be-resource-boolean-given-in/#findComment-1308193 Share on other sites More sharing options...
PFMaBiSmAd Posted January 16, 2012 Share Posted January 16, 2012 INSERT queries don't return result sets, so there's nothing to fetch. What exactly are you trying to accomplish, because performing two INSERT queries on the same table for different columns does not make any sense. Link to comment https://forums.phpfreaks.com/topic/255145-warning-mysql_fetch_array-expects-parameter-1-to-be-resource-boolean-given-in/#findComment-1308200 Share on other sites More sharing options...
scootstah Posted January 16, 2012 Share Posted January 16, 2012 INSERT queries don't return result sets, so there's nothing to fetch. Haha, good point - I totally over looked that... Link to comment https://forums.phpfreaks.com/topic/255145-warning-mysql_fetch_array-expects-parameter-1-to-be-resource-boolean-given-in/#findComment-1308203 Share on other sites More sharing options...
Muddy_Funster Posted January 16, 2012 Share Posted January 16, 2012 //Inset into database $insert_status = mysql_query(" insert into `status` (`status`, `date`) values ('$status', '$date')") or die (mysql_error()); //Line break after every 80 $status = wordwrap($status, 80, "\n", true); is all you need, just make sure and use backticks around field and table names that you have used reserved words to name. Link to comment https://forums.phpfreaks.com/topic/255145-warning-mysql_fetch_array-expects-parameter-1-to-be-resource-boolean-given-in/#findComment-1308210 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.