note 38489 added to function.time
| From: | calegoatcalegodotcc at rn2 dot php dot net | Date: | Tue, 23 Dec 2003 22:48:45 +0000 |
| Subject: | note 38489 added to function.time | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-62392@lists.php.net to get a copy of this message | ||
I am not sure exactly why, but for some reason the time() function did not operate properly when
placed in an equation and then compared to the database. I had this code;
<?php
$expiry = time() - 900;
mysql_query("DELETE FROM table WHERE refresh<=".$expiry);
?>
This did not carry out the query properly. I did this to check it: die($expiry), and it returned
nothing. The following fixed both the query and the die().
<?php
$expiry = intval(time()) - 900;
mysql_query("DELETE FROM table WHERE refresh<=".$expiry);
?>
Beware when placing timestamps in queries.
----
Manual Page -- http://www.php.net/manual/en/function.time.php
Edit -- http://master.php.net/manage/user-notes.php?action=edit+38489
Delete -- http://master.php.net/manage/user-notes.php?action=delete+38489&report=yes
Reject -- http://master.php.net/manage/user-notes.php?action=reject+38489&report=yes
Search -- http://master.php.net/manage/user-notes.php