saftmeister
Nutze den Saft!
Versuch mal das:
PHP:
$ip = $_SERVER['REMOTE_ADDR'];
$where = $_SERVER['REQUEST_URI'];
$timestamp = time();
$timeout = 300;
$noofrows = 0;
$result1 = mysql_query("SELECT * FROM usersonline") or die(mysql_error());
while ($ergebnis2 = mysql_fetch_array($result1)) // Fehlerzeile 1
{
if ($ergebnis2['ip'] == $ip) {
$noofrows = 1;
}
}
if ($noofrows == 1) {
mysql_query("UPDATE usersonline SET timestamp = '$timestamp', url = '$where' WHERE ip = '$ip'");
}
if ($noofrows == 0) {
mysql_query("INSERT INTO usersonline (ip, timestamp, url) VALUES ('$ip', '$timestamp', '$where')");
}
$alt = $timestamp-$timeout;
mysql_query("DELETE FROM usersonline WHERE timestamp < '$alt'");
$ergebnis3 = mysql_query("SELECT DISTINCT ip FROM usersonline") or die(mysql_error());
$online = mysql_num_rows($ergebnis3); // Fehlerzeile 2
if ($online == 1) {
echo "$online user online";
} else {
echo "$online users online";
}