Page 1 of 1

[SOLVED] strttome subracting seconds

Posted: Fri Mar 11, 2005 4:50 pm
by Burrito
I have this query:

Code: Select all

$getparts = mysql_query("select * from chatusers where room = '".mysql_escape_string($_GET['room'])."' and lasttime > ".strtotime("-10 seconds"));
but it's returning a bunch of rows when there really should only be 2 users who are within the 10 second range...can strtotime subract seconds?

Edit:
major brain fart on my part...I've revised my query to this:

Code: Select all

$partsqu = "select * from chatusers where room = '".mysql_escape_string($_GET['room'])."' and lasttime > '".date("Y-m-d H:i:s", strtotime("-10 seconds")."'");
but now I"m getting an error in my sql syntax ?? :S

Edit2: duh...another brain fart...I'm all good now...pretend this was never posted.

Burr

Re: strttome subracting seconds

Posted: Fri Mar 11, 2005 5:03 pm
by RobertGonzalez

Code: Select all

$partsqu = "select * from chatusers where room = '".mysql_escape_string($_GET['room'])."' and lasttime > '".date("Y-m-d H:i:s", strtotime("-10 seconds")."'");
Why not change your WHERE clause to:

Code: Select all

... and lasttime > " . time() - 10 . " ...
This should make it a little cleaner.