marksie1988 Posted June 10, 2007 Share Posted June 10, 2007 using php and mysql how can i tell the my website to move any entry older than 30 days to a different table and then delete it below i have some script i did try but this doesnt work (im using unix timestamp incase that changes anything) mysql_query(" INSERT INTO newsarchive (id, postdate, title, newstext) SELECT id, postdate, title, newstext FROM news WHERE postdate < DATE_SUB(curdate(), INTERVAL 30 DAY)"); mysql_query("DELETE FROM news WHERE postdate < DATE_SUB(curdate(), INTERVAL 30 DAY)"); mysql_close($link); //clean up Link to comment https://forums.phpfreaks.com/topic/55016-solved-delete-database-entry-after-30-days/ Share on other sites More sharing options...
Barand Posted June 10, 2007 Share Posted June 10, 2007 Try either ... WHERE FROM_UNIXTIME(postdate) < DATE_SUB(curdate(), INTERVAL 30 DAY) or ... WHERE postdate < UNIX_TIMESTAMP(DATE_SUB(curdate(), INTERVAL 30 DAY)) Link to comment https://forums.phpfreaks.com/topic/55016-solved-delete-database-entry-after-30-days/#findComment-271988 Share on other sites More sharing options...
marksie1988 Posted June 10, 2007 Author Share Posted June 10, 2007 tried both of these neither work anything else? Link to comment https://forums.phpfreaks.com/topic/55016-solved-delete-database-entry-after-30-days/#findComment-271996 Share on other sites More sharing options...
AndyB Posted June 10, 2007 Share Posted June 10, 2007 Define "neither of those work". Any errors? When you echo either of those query strings what do they contain? Link to comment https://forums.phpfreaks.com/topic/55016-solved-delete-database-entry-after-30-days/#findComment-272001 Share on other sites More sharing options...
marksie1988 Posted June 11, 2007 Author Share Posted June 11, 2007 i get nothing no errors or anything and how do i echo the querys :S sorry ive just never done that Link to comment https://forums.phpfreaks.com/topic/55016-solved-delete-database-entry-after-30-days/#findComment-272013 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.