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: - <?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);
-
?>
1 1347 Markus 6,050
Recognized Expert Expert
It sounds like you're not being very specific with your DELETE clause. What I mean is, it looks like multiple records could be getting deleted. This would mean that mysql_affected_ rows() may not necessarily be 1, but greater than one. So, I suggest you edit your IF statement to check for a value of greater than 0 (hint: > 0).
Hope this helps,
Markus.
Sign in to post your reply or Sign up for a free account.
Similar topics |
by: lawrence |
last post by:
I've two scripts, one to upload images, another to delete them. The
upload script works fine, but the delete script has permissions
trouble. How can PHP not have permission to delete an image it itself
uploaded?
Here is the delete script I'm using right now, and the error messages
I got below.
|
by: Gustaf Liljegren |
last post by:
I've been learning using PHP and MySQL from the tutorial at
freewebmasterhelp.com. Everything works fine, except deleting things.
The script is invoked with a URL like this:
http://www.example.org/test/delete_entry.php?id=35
And here's the script:
<?
include("dbinfo.inc.php");
|
by: Apostolis K. |
last post by:
I run windows XP and IIS 5.1 and the system doesn't let me to delete or move
folders using FileSystemObject.DeleteFolder(path,force) or
FileSystemObject.MoveFolder(origin,destination). I allow all permitions to
that web folder (Read, Right, Source Access)
I notice that in Windows XP cannot uncheck the Read-Only option in any
folder options. If you uncheck and press OK the next time you open the
folder properties again the check box will...
|
by: mpar612 |
last post by:
Hi everyone,
I appreciate all of your help with me and the problems I have been
having. I'm new to PHP and MySQL and I'm having some problems getting
this script to work. I can't get this to work and I don't understand
why. I don't get an error or anything, it almost seems like the page
refreshes. I went to the phpmyadmin and the row is still in the
database. The $_GET parts work perfectly in another script and the SQL
statement...
|
by: rajeshgujar |
last post by:
Here is What needs to be Done
In Your DataGrid do this
1 ] Private Sub DGReference_ItemDataBound(ByVal sender As Object,
ByVal e As System.Web.UI.WebControls.DataGridItemEventArgs) Handles
DGReference.ItemDataBound
e.Item.Cells(5).Attributes.Add("onclick", "return
confirmDelete (this.form);") // If its the 5 th Column in the
| |
by: Morteneistrom |
last post by:
Im a complete n00b at PHP so please forgive me if this i a stupid
question
Why wont the following work.
PHP Code:
<?php
foreach (glob('../images/profil/*.jpg') as $filename) {
echo "$filename <br>". "<a href="unlink('$filename');">Delete</
a>";
|
by: Gandalf |
last post by:
try this:
foreach(glob('../galleri/galleri/*', GLOB_ONLYDIR) as $key=$dirname)
{
$table.=($count%1==0)?"</tr>\n<tr>\n":"";
$table.="<td>".basename($dirname)."</td><td><input type='checkbox'
name ='deldir' value='$dirname'></td>\n";
$count++;
}
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look !
Part I. Meaning of...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it.
First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth.
The Art of Business Website Design
Your website is...
|
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
| |
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
|
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols.
I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
|
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
|
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...
| |