In this function I can't seem to get REMOTE_ADDR and PHP_SELF to come up. Yet if I run it as it's own script, it inserts into the databse, $REMOTE_ADDR and $PHP_SELF results just fine.
What is causing this?
Is there any work around to it? Or rather, another way to get the users IP address and put it into the db? (it is for unique counting purposes)
function useronline()
{
$timeoutseconds=1800;
$timestamp=time();
$timeout=$timestamp-$timeoutseconds;
mysql_query( "INSERT INTO useronline VALUES ('$timestamp','$REMOTE_ADDR','$PHP_SELF')");
mysql_query( "DELETE FROM useronline WHERE timestamp<$timeout");
$result=mysql_query( "SELECT DISTINCT ip FROM useronline WHERE file='$PHP_SELF'");
$user =mysql_num_rows($result);
if ($user==1){echo"<font color=\"white\" size=\"2\"><b>$user User is playing right now </b></font>";} else {echo"<font color=\"FFCC00\" size=\"3\"><b>$user Users playing right now</b></font>";}
}
You can see what it does as a seperate script at http://bbb.the-node.com