简体   繁体   中英

Sql select query (return results that are 120 seconds less than current time

This script worked just fine on my old server with php 4 compatibility. I moved to a new server that's php 5 only and it's not working please help. The script returns a list of members currently online, if the current time is no more than 120 seconds greater than their last activity time. The last activity time is updated every few seconds by another script as a timestamp (eg: 1308421786).

function getTimeStamp() {
return time();
 }

//Who's Online
$query_omoline = "SELECT * FROM ttourmember WHERE '".getTimeStamp()."'-`chatactive` <120 AND `chatactive`<>0 ORDER BY membername ASC";
$omoline = mysql_query($query_omoline) or die(mysql_error());
$row_omoline = mysql_fetch_assoc($omoline);
$totalRows_omoline = mysql_num_rows($omoline);

script then returns the results like this

<?php do { ?>
<?php
$omemname=$row_omoline['membername'];
$omemid=$row_omoline['memberid'];

if($totalRows_omoline>0){ ?>

<?php echo $row_omoline['membername'];  ?>

<?php }} while ($row_omoline = mysql_fetch_assoc($omoline)); ?>

try adding true to the time call time(true). That way it converts the result to a float, which can be used for arithmetic operations. I am not sure if that's the problem here, since the operation is done in SQL-land, but its worth a try.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM