jeppers Posted January 2, 2009 Share Posted January 2, 2009 //chck the form has been submitted if (isset($_POST['submitted'])) { if ($_POST['sure'] == 'yes') { //delete them //make the query $query = "DELETE foods, food_associations FROM foods, food_associations WHERE foods.food_id='$id' AND food_associations.food_id ='$id'"; $result = @mysql_query ($query) or die(mysql_error()); // Run the query. if (mysql_affected_rows() == 1) { // If it ran OK //print the message echo '<h1 "> Delete a food</h1> <p>The food has been deleted.</p><p><br /><br /></p>'; }else{ //if the query did not run ok echo '<h1 ">Sytem error</h1> <p class="error">The food could not be deleted due to a system error.</p>'; // public message echo '<p>' . mysql_error() . '<br /><br />Query: ' . $query . '</p>'; //debugging message. } The code above works and the query is correct. but every time i try to delete it comes up with this message "The food could not be deleted due to a system error" i then check the database and it has been deleted. can u have a look at the code and see if it something very simple thanks Link to comment https://forums.phpfreaks.com/topic/139212-not-sure-why-this-error-message-is-coming-up/ Share on other sites More sharing options...
PFMaBiSmAd Posted January 2, 2009 Share Posted January 2, 2009 How about echoing mysql_affected_rows() to see what it is. Since you are deleting from multiple tables, it is probably 2, not 1. Link to comment https://forums.phpfreaks.com/topic/139212-not-sure-why-this-error-message-is-coming-up/#findComment-728140 Share on other sites More sharing options...
jeppers Posted January 2, 2009 Author Share Posted January 2, 2009 what a fool this is the error $result = @mysql_query ($query) or die(mysql_error()); // Run the query. if (mysql_affected_rows() == 1) { // If it ran OK the query is effection 2 rows not one so all done thanks for all your help today Link to comment https://forums.phpfreaks.com/topic/139212-not-sure-why-this-error-message-is-coming-up/#findComment-728142 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.