Skylight_lady Posted January 14, 2011 Share Posted January 14, 2011 Hi Guys, How come i am unable to delete a record with the same id from multi records with the following php code? $rid = "SELECT month_ID FROM monthA WHERE userID = '".$_POST['userID']."' AND thisMonth = '".$_POST['month']."' AND thisYear = '".$_POST['year']."'"; $rid_month = mysql_query($rid); $row = mysql_fetch_array($rid_month); $month_ID = $row["month_ID"]; $rid = "SELECT * FROM monthB WHERE month_ID = '$month_ID'"; $rid_month = mysql_query($rid); $row = mysql_fetch_array($add_member); while ($row = mysql_fetch_array($rid_month)) { $month_ID = $row["month_ID"]; $rid = "DELETE FROM monthBB WHERE month_ID = '$month_ID' "; $result = mysql_query($rid); } $rid = "SELECT * FROM monthC WHERE month_ID = '$month_ID' "; $rid_month = mysql_query($rid); while ($row = mysql_fetch_array($rid_month)) { $month_ID = $row["month_ID"]; $rid = "DELETE FROM monthCC WHERE month_ID = '$month_ID' "; $result = mysql_query($rid); } $rid = "DELETE FROM monthA WHERE month_ID = '$month_ID' "; $result = mysql_query($rid); I have tried a number of ways without any luck. How ever if i use this code? mysql_query("DELETE FROM monthA WHERE month_ID = '$month_ID'"); It allows me to delete one row from one table only. Please advise Quote Link to comment Share on other sites More sharing options...
BlueSkyIS Posted January 14, 2011 Share Posted January 14, 2011 i suggest that every time you use mysql_query, you check for errors. there could be errors that you don't see. $rid_month = mysql_query($rid) or die(mysql_error() . " In $rid"); Quote Link to comment Share on other sites More sharing options...
BlueSkyIS Posted January 14, 2011 Share Posted January 14, 2011 but also, where is add_member coming from? $row = mysql_fetch_array($add_member); Quote Link to comment Share on other sites More sharing options...
Skylight_lady Posted January 14, 2011 Author Share Posted January 14, 2011 Sorry, i was changing the code for your view and changed all $add_member to $rid_month. missed one there. I'm actually redirecting the page after that final sql statement. It's not shown in the code. I'll disable the redirect and check for errors. 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.