Problem med online script
Jeg har dette online script som tjekker online brugere og tjekker hvem der er online, men der er noget galt med scriptet, jeg får ingen fejl men brugernavnet bliver ikke indsat af en eller anden grund, jeg har include det her script på alle sider:<?php
// database information
include("connect.php");
$player=$user_currently_loged;
// disconnected timeout
$timeout = 1800; // in seconds.. you can make it higher or lower.. i suggest keeping it at 1 minute
$yourstats="SELECT * from v_users where BINARY username like '$player'";
$yourstats2=mysql_query($yourstats) or die("Could not get your stats");
$yourstats3=mysql_fetch_array($yourstats2);
$test=$yourstats3[username];
// this will tell apart the people on your site
$ip=$_SERVER['REMOTE_ADDR'];
$times=time();
// remove old connections so that the number doesn't continue to rise like a counter
$onlinestats="SELECT * from joined WHERE hl < $times";
$onlinestats2=mysql_query($onlinestats) or die("Could not get your stats");
while ($onlinestats3 = mysql_fetch_array($onlinestats2)) {
$timeon=time();
$timerprot=$timeon-$onlinestats3[timeonline];
$tidminutter = (int) ($timerprot/60);
$updateyourstats="update v_users set minonline=minonline+'$tidminutter' where BINARY username like '$onlinestats3[username]'";
mysql_query($updateyourstats) or die("Could not update your stats");
}
$strq = "DELETE FROM joined WHERE hl < $times";
$qry = mysql_db_query($dbname,$strq);
$strq = "SELECT count(*) FROM joined WHERE IP='$ip'";
$qry = mysql_db_query($$dbname,$strq);
while ( $r = @mysql_fetch_array($qry) ) {
$ppl = $r["count(*)"];
}
if ($cpt) {
// checks for reloads, etc..
$strq = "UPDATE joined SET hl=hl + $timeout WHERE ip='$ip'";
} else {
// confirmed user updated into database
$times=time()+1800;
$normaltime=time();
$strq = "INSERT INTO joined (ip, hl, username, timeonline) VALUES ('$ip','$times','$player','$normaltime')";
}
$qry = mysql_db_query($dbname,$strq);
// display the number of connected people
$strq = "SELECT count(*) FROM joined";
$qry = mysql_db_query($dbname, $strq);
while ( $result = @mysql_fetch_array($qry) ) {
$ppl = $result["count(*)"];
}
$yourstats="SELECT * from v_users where BINARY username like '$player'";
$yourstats2=mysql_query($yourstats) or die("Could not get your stats");
$yourstats3=mysql_fetch_array($yourstats2);
$tidloggetind = time() - $yourstats3[lastlogin];
$tidtimer = (int) ($tidloggetind/3600);
if ($tidtimer < 3){
}else{
echo('<script type=\'text/javascript\'>parent.location.href=\'login.php\';</script>');
}
?>
