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 Quote Link to comment 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. Quote Link to comment 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 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.