Hi. I can't get DELETE to work. When the user selects a checkbox called 'delete' (with value set to "1"), a row containing a specific 'id' in table 'retail_listings' should get deleted. The script appropriately prints "Deleting retail listing..." and refreshes, but the row never actually gets deleted. I don't get an error message. The problem shouldn't be related to 'admin_connect.php' or '$id' because the 'if ($mod)' portion works perfectly, and the echo $id displays the correct id. Also, the SQL privilages for the user in 'admin_connect.php' are set to ALL. I've checked the syntax for the DELETE statement over and over. I'm sure that I'm overlooking something simple. Thanks.
--brian
//connect script
require 'admin_connect.php';
//if form was submitted and 'delete' was checked then delete record
if ($delete==1){
$sql = "DELETE FROM 'retail_listings' WHERE id='$id'" or die ("Unable to Make the Query:" . mysql_error() );
echo $id; //just to test that $id is being sent by the form
// display message and return to 'mod_location.php'
print "<font color=\"#333333\" size=\"3\" face=\"Arial, Helvetica, sans-serif\">Deleting retail listing...</font>";
print "<META HTTP-EQUIV=\"refresh\" content=\"1;URL=mod_location.php\" target=\"_self\">";
exit;
}
//if form was submitted and 'delete' was not checked then update database
if ($mod){
$sql = "UPDATE retail_listings SET name='$name', street='$street', city='$city', state='$state', zip='$zip', phone='$phone', other='$other' WHERE id='$id'" or die ("Unable to Make the Query:" . mysql_error() );
$result = mysql_query($sql) or die ('Query error: '.mysql_error());
// display message and return to 'mod_location.php'
print "<font color=\"#333333\" size=\"3\" face=\"Arial, Helvetica, sans-serif\">Please wait...</font>";
print "<META HTTP-EQUIV=\"refresh\" content=\"1;URL=mod_location.php\" target=\"_self\">";
exit;
}