Ok, for some reason, I just can't seem to delete a row from MySQL using PHP. I've tried to alter my code several ways, but I must just be missing something simple. :bemused:
<?
require '../db_connect.php';
if ($logged_in == 1) {
include ("../../header.php");
$id=$_GET['query'];
$confirm=$_GET['confirm'];
$query = "SELECT `auto_id`, `name_first`, `name_last`, `email`, `city`, `state`, `country`, `zip_postal`, `phone_1`, `phone_2`, `phone_3`, `AskingPrice`, `type`, `phone_forgeign`, `contact_email`, `contact_phone`, `mostrecentcheck`, `mostrecentdate`, `priorcheck1`, `priorcheckdate1`, `priorcheck2`, `priorcheckdate2`, `priorcheck3`, `priorcheckdate3`, `priorcheck4`, `priorcheckdate4`, `priorcheck5`, `priorcheckdate5`, `LeaseName`, `LocationCity`, `LocationState`, `DecInterest`, `OpName`, `LegalDiscription` FROM `entries` WHERE auto_id = $id";
$result = mysql_query($query) or die("Query failed");
$row = mysql_fetch_array($result);
if ($confirm == "yes") {
$sql = "DELETE FROM entries WHERE auto_id=$id";
$removeWid = mysql_query($sql);
$title = "Deleted";
$redirect = "<meta HTTP-EQUIV=\"REFRESH\" content=\"5; url=../index.php\">";
$delete = "<b>Entry Deleted. Redirection to Main Page will occur in five seconds, or click You will automatically be re-directed to the frontpage in <u>5</u> seconds.</b><br>
(If re-direction doesn't occur, click <a href=\"../index.php\">here.</a>)";
} else {
$title = "Are you sure?";
$redirect = "";
$delete = "Make sure you want to delete this entry. <br>If you accidently delete it, <br>you won't be able to get it back.
<br><br><br><br><font size=\"16\"><a href=\"delete.php?id=$id&confirm=yes\">Delete</a></font>";
}
;
$print = "
<html>
<head>
$redirect
<title>$title</title>
</head>
<body>
<center>
<br><br><br><br><br><br><br><br><br><br><br>
$delete
</center>
</body>
</html>
"
;
print $print;
} else {
header( 'Location: ../login.php' )
;
}
?>
Also, I don't need to have
$query = "SELECT `auto_id`, `name_first`, `name_last`, `email`, `city`, `state`, `country`, `zip_postal`, `phone_1`, `phone_2`, `phone_3`, `AskingPrice`, `type`, `phone_forgeign`, `contact_email`, `contact_phone`, `mostrecentcheck`, `mostrecentdate`, `priorcheck1`, `priorcheckdate1`, `priorcheck2`, `priorcheckdate2`, `priorcheck3`, `priorcheckdate3`, `priorcheck4`, `priorcheckdate4`, `priorcheck5`, `priorcheckdate5`, `LeaseName`, `LocationCity`, `LocationState`, `DecInterest`, `OpName`, `LegalDiscription` FROM `entries` WHERE auto_id = $id";
couldn't I just have
$query = "SELECT `auto_id` FROM `entries` WHERE auto_id = $id";
and have the same effect?
Thanks.