PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!
<?
require 'db_connect.php';
if (strstr($_SERVER['REMOTE_ADDR'], ', ')) {
$ips = explode(', ', $_SERVER['REMOTE_ADDR']);
$uvisitor = $ips[0];
} else {
$uvisitor = $_SERVER['REMOTE_ADDR'];
}
$exptime=$utime-600; // (in seconds)
@mysql_query("delete from online where timevisit<$exptime");
$uexists=@mysql_num_rows(@mysql_query("select id from online where visitor='$uvisitor'"));
if ($uexists>0){
@mysql_query("update online set timevisit='$utime' where visitor='$uvisitor'");
} else {
@mysql_query("insert into online (visitor,timevisit) values ('$uvisitor','$utime')");
}
$rs=@mysql_query("select * from online");
echo "<style><!--\n";
echo "body {font-family:verdana;font-size:10pt}\n";
echo "td {font-family:verdana;font-size:10pt}\n";
echo "--></style>\n";
echo "<div align=center><table><tr bgcolor=#CCCCCC><td><b>Visitor
IP/Host<td><b>Last visit</tr>";
while ($ro=@mysql_fetch_array($rs)){
echo "<tr><td>".$ro[visitor]."<td>".date('j M Y - H:i',$ro[timevisit])."</tr>";
}
echo "</table></div>";
$jmlonline=@mysql_num_rows(@mysql_query("select id from online"));
echo "<div align=center><b>There are $jmlonline user online</b></div>";
?>
this is the whosonline.php script. Why is it giving me this error? How can I fix it? Also, how would I get the id's into the table, would I need to include some code in my login page? If so, what would I need to write?
thanks
Last edited by fresh on Sun Jul 04, 2004 11:54 pm, edited 1 time in total.
thanks alot, that script worked and took care of the warning...
one question though... how would I get the IP's into my DB table 'online'...?
Do I need to put some script in with my login page, which issuse the sid and such, but does not currently add anything to the online table... I don't have any idea how to go about adding to the online table, or where to do so, I logged in and when I goto the whosonline page, it says 0 users online, so I check the db and no entries go to the table... so I suppose I need to do so within the login page, however, I have no idea how to do so... any help?