GotYourMonet
Nov 7 2009, 06:18 PM
Hi everyone. I have a beginner's question about deleting an entry from my database via PHP. I am using the following code with no errors, and the if statement evaluates to true, and yet the entry is not getting deleted. How can the query return true with no errors while the actual deletion does not take place?
$id = $_GET['confirmdelete']);
$deleteuser = mysql_query( "DELETE FROM Users WHERE ID = '$id'");
if($deleteuser) {
echo('User deleted.');
}
Thanks for your time and any help you can offer.
swordz
Nov 7 2009, 11:11 PM
$deleteuser = mysql_query("DELETE FROM Users WHERE `ID` = '$id'");
Try that.
You are aware that I could delete all your users with this code? You do need to sanitise your inputs.
swordz.
GotYourMonet
Nov 8 2009, 06:08 AM
Thanks for replying. I will try your suggestion this afternoon, although I wonder why the quotes would be helpful? Haven't needed them in any other SQL query.
I see what you're saying about the potential for abuse, I had covered it from another angle; only users logged in with administration privileges can perform this operation, it won't work otherwise. But if you care to share whatever thoughts you had on that one, I'm happy to listen.
This is a "lo-fi" version of our main content. To view the full version with more information, formatting and images, please
click here.