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 Quote 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)) Quote 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? Quote 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? Quote 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 Quote 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
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.