Jump to content

Deleting from database


dreampho

Recommended Posts

Hi. Thanks for getting back to me.

 

Okay, how would I validate? I am a complete newbie.

 

I want the row with the id of the post variable to be deleted. I can echo the post variable, so I know its passing over the correct id, it just doesnt actually delete. I think I have the wrong quotes or something around the post variable.

 

Thanks

Take a look at mysql_real_escape_string or in this case, type casting (you'll want to cast to an int).

 

Your quotes are fine, though you don't need quotes around numeric data types. Try some debugging.

 

$id = (int) $_POST['id'];
if (!mysql_query("DELETE FROM availability WHERE id = $id")) {
  trigger_error(mysql_error());
}

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.