jbrill Posted May 9, 2007 Share Posted May 9, 2007 Hey, I have a php file that handles all the delee functions of various tables in my database. however it only wokrs on certain hosting servers. I have tried using 2 different companies i host with and it works fine on their servers, but will not work on my most recent company's.... I can add, modify etc, but it will not allow me to delete. Here is the code for: "delete.php" <? // this file is the file that handles deleting entries. include 'header.php'; // this part validates the user logged in if($_SESSION['logged'] != "valid") { include 'loginmsg.php'; } else{ if($_POST['submit']) { // scripts to delete things if($_POST['table'] == "user") {// if the table to remove from is the user table $sql = "DELETE FROM users WHERE id='".$_POST['idr']."'"; mysql_query($sql); if (mysql_affected_rows() > 0) {echo "User Deleted"; echo "<META HTTP-EQUIV=\"Refresh\" CONTENT=\"2; URL=admin_finduser.php\">";} } if($_POST['table'] == "products") {// if the table to remove from is the product table $sql = "DELETE FROM products WHERE id='".$_POST['idr']."'"; mysql_query($sql); if (mysql_affected_rows() > 0) {echo "Product Deleted"; if($_POST['hopcat']!="") {$hopcat = "cat=".$_POST['hopcat'];} if($_POST['hopsubcat']!="") {$hopsubcat = "subcat=".$_POST['hopsubcat'];} echo "<META HTTP-EQUIV=\"Refresh\" CONTENT=\"0; URL=admin_findprod.php?".$hopcat.$hopsubcat."\">";} } if($_POST['table'] == "inquiry") {// if the table to remove from is the inquiry table $sql = "DELETE FROM inquiry WHERE id='".$_POST['idr']."'"; mysql_query($sql); if (mysql_affected_rows() > 0) {echo "inquiry Deleted"; echo "<META HTTP-EQUIV=\"Refresh\" CONTENT=\"1; URL=admin_inquiries.php\">";} } if($_POST['table'] == "news") {// if the table to remove from is the news table $sql = "DELETE FROM news WHERE id='".$_POST['idr']."'"; mysql_query($sql); if (mysql_affected_rows() > 0) {echo "News Deleted"; echo "<META HTTP-EQUIV=\"Refresh\" CONTENT=\"1; URL=admin_news.php\">";} } if($_POST['table'] == "contact") {// if the table to remove from is the contact table $sql = "DELETE FROM contact WHERE id='".$_POST['idr']."'"; mysql_query($sql); if (mysql_affected_rows() > 0) {echo "Contact Information Deleted"; echo "<META HTTP-EQUIV=\"Refresh\" CONTENT=\"1; URL=admin_contact.php\">";} } if($_POST['table'] == "partners") {// if the table to remove from is the partners table $sql = "DELETE FROM partners WHERE id='".$_POST['idr']."'"; mysql_query($sql); if (mysql_affected_rows() > 0) {echo "Partner Deleted"; echo "<META HTTP-EQUIV=\"Refresh\" CONTENT=\"1; URL=admin_partners.php\">";} } } else {// the form itself before values are submitted ?> <table align=center> <tr> <td align=center> <form action="<?echo $PHP_SELF;?>" method="post"> <input type="Hidden" name="submit" value="1"> <input type="hidden" name="idr" value="<?echo $idr;?>"> <input type="hidden" name="table" value="<? echo $_GET['table']?>"> <input type="Hidden" name="hopcat" value="<?echo $_GET['cat'];?>"> <input type="Hidden" name="hopsubcat" value="<?echo $_GET['subcat']?>"> <input type="hidden" name="delete" value="1"> <font class=input>Click Submit if you would like to delete the item for sure.</font><br><br> <input type="Submit" value="Delete"> </td> </tr> </table> <? } } include 'footer.php'; ?> Quote Link to comment https://forums.phpfreaks.com/topic/50712-delete-function-not-working/ Share on other sites More sharing options...
Daniel0 Posted May 9, 2007 Share Posted May 9, 2007 Chances are that you do not have privileges to delete on the two servers which it does not work on (although I don't see any reason why they would restrict that). Does the code above display any errors on the servers it doesn't work on? Is it the query that doesn't work? Have you tried running the query directly on the database (e.g. with a tool like phpMyAdmin)? Or is the code itself that doesn't work? Quote Link to comment https://forums.phpfreaks.com/topic/50712-delete-function-not-working/#findComment-249341 Share on other sites More sharing options...
jbrill Posted May 11, 2007 Author Share Posted May 11, 2007 for some reason when i switched it form _POST to _GET it worked! Quote Link to comment https://forums.phpfreaks.com/topic/50712-delete-function-not-working/#findComment-250748 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.