Bubblychaz Posted November 23, 2012 Share Posted November 23, 2012 (edited) My php script wont delete in selected id from the mysql database function code <?php function edit_avatar($_POST) { if ($_POST['delete'] == 1) { delete_item($_POST['id']); return 'deleted'; } $errors = check_required_fields($_POST); function delete_avatars($id) { $query = "DELETE FROM avatar_list WHERE id = '$id' LIMIT 1"; return mysql_query($query) or die(mysql_error()); } edit page code if (!empty($_GET['delete'])) { echo '<p style="color: green;">The avatar has been deleted.</p>'; } <td>Delete Avatar:</td> <td><input type="checkbox" name="delete" value="1" onclick="confirm_delete(this);"/><span style="color:red;">This cannot be undone!</span></td> Ive removed the rest of the code but delete bits Edited November 23, 2012 by Bubblychaz Quote Link to comment https://forums.phpfreaks.com/topic/271081-script-wont-delete/ Share on other sites More sharing options...
mrMarcus Posted November 23, 2012 Share Posted November 23, 2012 Posting only relevant code would be more helpful. And point out the issues you're experiencing. Quote Link to comment https://forums.phpfreaks.com/topic/271081-script-wont-delete/#findComment-1394640 Share on other sites More sharing options...
Bubblychaz Posted November 23, 2012 Author Share Posted November 23, 2012 Okay sure. When i clikc on Delete in my form, It just returns the next page blank, But when you then go back to the list, the Id you just deleted is still there Quote Link to comment https://forums.phpfreaks.com/topic/271081-script-wont-delete/#findComment-1394642 Share on other sites More sharing options...
PFMaBiSmAd Posted November 23, 2012 Share Posted November 23, 2012 What have you done to pin down exactly at what point your code and data are doing what you expect and at what point it is not? I can guarantee that the problem lies somewhere between those two points. If all you have done is run your code and it doesn't work, all you have pined the problem down to is 'somewhere in your code.' Is your code taking the expected execution path? Is the input data what you expect? The reasons I ask this is - 1) We cannot run your code, because we don't have all of it (nor do we want you to post all of it) and we don't have your database tables or any data (nor do we want you to post this.) 2) We are not going to look through 100's of lines of mostly non-relevant code trying to find just the few lines that are relevant. Quote Link to comment https://forums.phpfreaks.com/topic/271081-script-wont-delete/#findComment-1394644 Share on other sites More sharing options...
mrMarcus Posted November 23, 2012 Share Posted November 23, 2012 My php script wont delete in selected id from the mysql database function code <?php function edit_avatar($_POST) { if ($_POST['delete'] == 1) { delete_item($_POST['id']); return 'deleted'; } $errors = check_required_fields($_POST); function delete_avatars($id) { $query = "DELETE FROM avatar_list WHERE id = '$id' LIMIT 1"; return mysql_query($query) or die(mysql_error()); } edit page code if (!empty($_GET['delete'])) { echo '<p style="color: green;">The avatar has been deleted.</p>'; } <td>Delete Avatar:</td> <td><input type="checkbox" name="delete" value="1" onclick="confirm_delete(this);"/><span style="color:red;">This cannot be undone!</span></td> Ive removed the rest of the code but delete bits Thanks. I'm simply guessing the edit_avatar() function gets called, then delete_item() function? I don't see where delete_avatars() is being called. Should you be calling delete_avatars() instead of delete_item()? Or is delete_item() part of a larger function that calls delete_avatars() separately? Quote Link to comment https://forums.phpfreaks.com/topic/271081-script-wont-delete/#findComment-1394645 Share on other sites More sharing options...
Pikachu2000 Posted November 23, 2012 Share Posted November 23, 2012 Please, turn on error reporting before you post any more questions, and include any errors that are generated. In your php.ini file, make sure the following lines exist, and are not commented out with a leading semicolon: error_reporting = -1 display_errors = On Then restart Apache so the changes take effect. Quote Link to comment https://forums.phpfreaks.com/topic/271081-script-wont-delete/#findComment-1394648 Share on other sites More sharing options...
Bubblychaz Posted November 23, 2012 Author Share Posted November 23, 2012 It isnt my code, It was partly made for me but the guy never finnished it all. All that is left to do is the delete function.. Sorry yes it should be delete_avatars Quote Link to comment https://forums.phpfreaks.com/topic/271081-script-wont-delete/#findComment-1394657 Share on other sites More sharing options...
Bubblychaz Posted November 23, 2012 Author Share Posted November 23, 2012 I couldnt find my php.ini file My webhost said error reporting is on Quote Link to comment https://forums.phpfreaks.com/topic/271081-script-wont-delete/#findComment-1394658 Share on other sites More sharing options...
Bubblychaz Posted November 23, 2012 Author Share Posted November 23, 2012 Thanks. I'm simply guessing the edit_avatar() function gets called, then delete_item() function? I don't see where delete_avatars() is being called. Should you be calling delete_avatars() instead of delete_item()? Or is delete_item() part of a larger function that calls delete_avatars() separately? Its fixed.. Thank you. Quote Link to comment https://forums.phpfreaks.com/topic/271081-script-wont-delete/#findComment-1394659 Share on other sites More sharing options...
Pikachu2000 Posted November 23, 2012 Share Posted November 23, 2012 Why are you attempting to do development on a live server? Set up a local development environment that matches your server's environment, except with error reporting set up at maximum levels. You'll save yourself a ton of time. Quote Link to comment https://forums.phpfreaks.com/topic/271081-script-wont-delete/#findComment-1394661 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.