dark dude Posted July 8, 2006 Share Posted July 8, 2006 This isnt working:[quote]<?include("dbinfo.inc.php");mysql_connect(localhost,$username,$password);@mysql_select_db($database) or die( "Unable to select database");$2days = TIMESTAMP(NOW()) - 172800; $query="DELETE FROM Messages WHERE DateSent<'$2days'";mysql_query($query);echo "Messages Updated";?>[/quote]I want it to delete all files older than 2 days from the database when the script activates, but it doesnt work full stop (Blank screen comes up).Help much appreciated ^_^ Quote Link to comment https://forums.phpfreaks.com/topic/14054-timestamp-problem/ Share on other sites More sharing options...
ShogunWarrior Posted July 8, 2006 Share Posted July 8, 2006 I think the problem is that there is no such function as TIMESTAMP or NOW, if you want it to be included in theSQL query as text then you will need to enclose it in quotes.[code]$2days = '(TIMESTAMP(NOW()) - 172800)'; [/code]Instead of:[code]$2days = TIMESTAMP(NOW()) - 172800; [/code]Also, why not put[code]echo ( mysql_error() );[/code]And it should output the problem if it is with your SQL.Cheers. Quote Link to comment https://forums.phpfreaks.com/topic/14054-timestamp-problem/#findComment-54939 Share on other sites More sharing options...
toplay Posted July 8, 2006 Share Posted July 8, 2006 You're not seeing your PHP errors because this line is not right (no quotes):$2days = TIMESTAMP(NOW()) - 172800;Try this:$query = 'DELETE FROM Messages WHERE UNIX_TIMESTAMP(DateSent) < UNIX_TIMESTAMP(NOW()) - 172800';mysql_query($query);FYI:While testing/debugging, make sure you have error_reporting(E_ALL); at the top of your script so you can see all of PHP's errors/warnings/notices. Also, I assume you have display_errors on in the php.ini file. Otherwise, set it using ini_set('display_errors', '1'); at the top of your script too. Quote Link to comment https://forums.phpfreaks.com/topic/14054-timestamp-problem/#findComment-54942 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.