[ damakii @ 01.03.2012. 08:15 ] @
Zdravo, pokušavam da napravim brojač trenutnog broja online korisnika. Uradio sam sljedeće: Code: <? //online $server = ""; // usually localhost $db_user = ""; $db_pass = ""; $database = ""; $timeoutseconds = 300; // length of gaps in the count //get the time $timestamp = time(); $timeout = $timestamp-$timeoutseconds; //connect to database mysql_connect($server, $db_user, $db_pass); //insert the values $insert = mysql_db_query($database, "INSERT INTO useronline VALUES ('$timestamp','$REMOTE_ADDR','$PHP_SELF')"); if(!($insert)) { print ""; } //delete values when they leave $delete = mysql_db_query($database, "DELETE FROM useronline WHERE timestamp<$timeout"); if(!($delete)) { print ""; } //grab the results $result = mysql_db_query($database, "SELECT DISTINCT ip FROM useronline WHERE file='$PHP_SELF'"); if(!($result)) { print ""; } //number of rows = the number of people online $user = mysql_num_rows($result); if(!($user)) { print("ERROR: " . mysql_error() . "\n"); } //spit out the results mysql_close(); print("Trenutno online: $user"); ?> Međutim nešto ne radi kako treba, u bazu mi upisuje samo time stamp, a ip i file ne upisuje. Pored toga uvijek mi stoji broj 1 ma koliko usera bilo online. Molim za pomoć. |