Bullet Posted August 21, 2008 Share Posted August 21, 2008 if (strip_tags($_POST['clear'])){ mysql_query("DELETE * FROM `search` WHERE `username`='$username'"); echo "All searches deleted!"; } Thats my script. Any help? When ever I click the button it doesn't delete. Link to comment https://forums.phpfreaks.com/topic/120680-solved-why-not-just-delete/ Share on other sites More sharing options...
Fadion Posted August 21, 2008 Share Posted August 21, 2008 Your code would work only if you have register_globals on. If so, I suggest to turn it off in your php.ini as it is deprecated and removed from the upcoming php6. A normal code should be: <?php if(isset($_POST['clear'])){ $username = mysql_real_escape_string($_POST['clear']); //or whatever post variable you are using $results = mysql_query("DELETE FROM search WHERE username='$username'"); echo 'All searches deleted'; } ?> I also modified the query as the delete syntax is: "DELETE FROM table WHERE column='value'" and smart quotes aren't necessary. Try it and see if it works now. Link to comment https://forums.phpfreaks.com/topic/120680-solved-why-not-just-delete/#findComment-621865 Share on other sites More sharing options...
Bullet Posted August 21, 2008 Author Share Posted August 21, 2008 Thanks it worked! Link to comment https://forums.phpfreaks.com/topic/120680-solved-why-not-just-delete/#findComment-621872 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.