...

View Full Version : Delete from old messages not working



masterofollies
07-24-2008, 01:43 AM
I set up a cron job to run every 6 hours to delete old messages from users past 60 days old. But it won't work. This is the entire coding excluding the database username and password stuff.


<?php

$postdate = date(
'Y-m-d H:i:s', // 0000-00-00 00:00:00
time() - ( 60 * 60 * 24 * 60 ) // 60 days into the past
);
mysql_query( "DELETE FROM `messages` WHERE `postdate` < '{$postdate}'" ) or exit( mysql_error() );

?>

kbluhm
07-24-2008, 02:04 AM
What MySQL error is displayed, if any?

masterofollies
07-24-2008, 02:39 AM
The cron doesn't send me an email, and it doesn't delete the messages. If I run it myself it doesn't do anything, it's a blank page (which is normal there is no text in it) and no errors are displayed.

ShaneC
07-24-2008, 04:12 AM
The cron doesn't send me an email, and it doesn't delete the messages. If I run it myself it doesn't do anything, it's a blank page (which is normal there is no text in it) and no errors are displayed.

Does the script do it's job when you execute it though? If so, it's cron. If not, it's PHP.

masterofollies
07-24-2008, 02:25 PM
Nope if I run it manually then it does nothing.

masterofollies
07-24-2008, 03:14 PM
I tried changing the < to a > and that made all messages be deleted. So if that works then the query does in fact work, but just the time isn't working.

kbluhm
07-24-2008, 03:24 PM
I tried changing the < to a > and that made all messages be deleted.
Of course... I already went over that with you (http://www.codingforums.com/showpost.php?p=715053&postcount=6). :thumbsup:

Are you sure there were messages older than 60 days in there?

ShaneC
07-24-2008, 03:41 PM
I'm starting to think something may be wrong with your time statements but I'm so poor with that I don't want to risk giving you advice on it until you exhaust your other options :p.

masterofollies
07-24-2008, 11:32 PM
Yeah I had some from May 2nd. But it looks like it did delete a few pages worth. Let me run a test of like 59 days and like 20 hours and see if it disappears.

masterofollies
07-25-2008, 02:39 AM
Ok it really does work now. Thanks!!!!!



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum