RON_ron Posted December 6, 2012 Share Posted December 6, 2012 I'm trying to delete a complete row from 3 databases. But it's not functioning. I can't see an error. Could someone help? $sperson = mysql_real_escape_string($_POST['sperson']); $sqlA="DELETE FROM showrooms WHERE salesperson = '".$sperson."'"; $result1=mysql_query($sqlA); $sqlB="DELETE FROM supplier WHERE salesperson = '".$sperson."'"; $result2=mysql_query($sqlB); $sqlC="DELETE FROM data WHERE salesperson = '".$sperson."'"; $result3=mysql_query($sqlC); if($result1 && $result2 && $result3){ $login = "Success"; echo($login); } else { $login = "failed"; echo($login); }; Quote Link to comment https://forums.phpfreaks.com/topic/271672-delete3/ Share on other sites More sharing options...
Christian F. Posted December 6, 2012 Share Posted December 6, 2012 You're not handling the MySQL errors, so it's quite impossible to say why it fails. I recommend reading this post by Jessica, as it'll explain in detail what you should do. Quote Link to comment https://forums.phpfreaks.com/topic/271672-delete3/#findComment-1397840 Share on other sites More sharing options...
PFMaBiSmAd Posted December 6, 2012 Share Posted December 6, 2012 Define: But it's not functioning? What result are you getting? What output or symptom occurred in front of you that leads you to believe it's not functioning? If you are getting a 'Success' message, but the rows are not being deleted, the only thing your conditional code at the end is doing is testing if the queries ran without any errors. That doesn't mean they actually deleted anything, which would occur if the WHERE clause is FALSE (i.e. the $sperson variable is empty or doesn't match any entry in the table(s).) You would need to both test if the queries executed without any error and use mysql_affected_rows to determine if any row(s) were actually deleted before outputting a 'Success' message. Quote Link to comment https://forums.phpfreaks.com/topic/271672-delete3/#findComment-1397842 Share on other sites More sharing options...
RON_ron Posted December 6, 2012 Author Share Posted December 6, 2012 (edited) This is the error message when I did a echo mysql_error(); command denied to user 'abcb_showrooms'@'localhost' for table 'data' Edited December 6, 2012 by RON_ron Quote Link to comment https://forums.phpfreaks.com/topic/271672-delete3/#findComment-1397876 Share on other sites More sharing options...
mrMarcus Posted December 6, 2012 Share Posted December 6, 2012 The user 'abcb_showrooms' does not have permission to use DELETE. You need to grant that user the proper permissions. Quote Link to comment https://forums.phpfreaks.com/topic/271672-delete3/#findComment-1397878 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.