I'm using the delete script below. It's deleting and sending the email OK, but the correct information is not being sent.
I tested this script on one database and it deleted several ads, but the email I received said that "No ads were deleted." How do I fix this?
delete_old.php:
I tested this script on one database and it deleted several ads, but the email I received said that "No ads were deleted." How do I fix this?
delete_old.php:
Code:
<?php
include("dbconnect.php");
$query = "DELETE FROM ads WHERE submitted < SUBDATE(NOW(), INTERVAL 45 DAY)";
$result = mysql_query($query);
if (mysql_affected_rows() == 1)
{ // A record was deleted.
$action = $result;
} else {
$action = "No ads were deleted.";
}
// Send the email.
$when = date('j M Y h:i:s A');
$email = "here@there.com";
$subject = "Ad Deletion";
$body = "Date: <b>$when</b><br><br> Results: $action";
$headers = "From: there@here.com\n";
$headers .= "Content-Type: text/html; charset=iso-8859-1\n";
mail ($email, $subject, $body, $headers);
?>
Comment