Results 1 to 4 of 4
-
06-16-2009, 06:07 PM #1Junior Guru
- Join Date
- Apr 2009
- Location
- Scotland
- Posts
- 177
Delete Older then 1 Day from DB [MySQL & PHP]
Hi.
I want too delete records from a database that are over 1 day old, Id like this too happen when someone requests the page with the code on it (I dont require a cron job (I dont know how too use them))
This is what Ive tried soo far
PHP Code:$sql = 'DELETE FROM table WHERE `when` < DATE_SUB(CURDATE(), INTERVAL 1 Day)';
$result = mysql_query($sql);
Darren Tod
RPD Hosting
-
06-16-2009, 06:53 PM #2Retired Moderator
- Join Date
- Feb 2005
- Location
- Australia
- Posts
- 5,849
Looks like it should work. Is your field ("when") a datetime type?
Chris
"Some problems are so complex that you have to be highly intelligent and well informed just to be undecided about them." - Laurence J. Peter
-
06-17-2009, 04:50 AM #3Junior Guru
- Join Date
- Apr 2009
- Location
- Scotland
- Posts
- 177
Hi.
Ye heres the structure
Code:`when` datetime default NULL,
Darren Tod
RPD Hosting
-
06-17-2009, 04:58 AM #4Junior Guru
- Join Date
- Apr 2009
- Location
- Scotland
- Posts
- 177
Aplogies, I had the when field named as 'datecode', after I renamed it, it appears too be working, I wont know till tomorrow tho
Darren Tod
RPD Hosting