Basically, i got the codes to create live counter.
<?php
// insert mysql init here...
$ip = $_SERVER['REMOTE_ADDR'];
$now = time ();
$now_5 = $now - 300; // refresh every 5 min
sql_query ("DELETE FROM live WHERE last_access < $now_5");
$res = mysql_query ("SELECT * FROM live WHERE ip='$ip' LIMIT 1");
if (!$row = mysql_fetch_array ($res))
{
mysql_query ("INSERT INTO live SET ip='$ip', last_access = '$now'");
}
else
{
mysql_query ("UPDATE live SET last_access = '$now' WHERE idx='$row[idx]' LIMIT 1");
}
// display them
$txt = ''; $n = 0;
$res = mysql_query ("SELECT * FROM live");
while ($row = mysql_fetch_array ($res))
{
$n++;
$txt .= "IP: $row[ip] - Last Access: ".date ('r', $row['last_access'])."<BR>";
}
$txt = "There are/is $n visitor(s) now:<BR>".$txt;
echo $txt;
?>
i get this undefined error message of this function sql_query.
But if i change it to mysql_query it works. So I'm wondering if its ok?
heres the link to the codes : http://magix.c97.net/read.php?15