Hi
I am trying to add a php script which queries a mysql table for my hit counter. When I upload the whole script as a seperate page to my website it works, but I'd like to integrate as html on my main website page just to see the counter.
I've included the script, any help would really be appreciated.
Thanks
Theo
include('config.php');
$date = date("d-m-Y" );
$time = time();
$select = "SELECT * FROM " . $pre . "counter WHERE ip = '$ip' AND date = '$date'";
$query = mysql_query($select);
while($l = mysql_fetch_object($query)){
$time2 = $l->time;
if($time2 > $time - $Dtime) $noentry = 1 ;
}
if(!$noentry){
$insert = "INSERT INTO " . $pre . "counter (ip, date, time) VALUES('$ip', '$date', '$time')";
$query = mysql_query($insert) or die(mysql_error());
}
$select = "SELECT * FROM " . $pre . "counter";
$query = mysql_query($select);
$num = mysql_num_rows($query);
$iparray = array();
$i = 0;
while($l = mysql_fetch_object($query)){
$ip2 = $l->ip;
$isin = 0;
$count = count($iparray);
if(!$count) $isin = 0;
for($j = 1; $j < $count + 1; $j++ ){
if($iparray[$j] == "$ip2") $isin = 1;
}
if(!$isin){
$i++;
$iparray[$i] = "$ip2";
}
}
$count = count($iparray);
echo "Hits: " . $num . "<br>";
echo"Unique hits: " . $count;
echo'<br /><a href="image.php">This month\'s chart</a>';
?>
I am trying to add a php script which queries a mysql table for my hit counter. When I upload the whole script as a seperate page to my website it works, but I'd like to integrate as html on my main website page just to see the counter.
I've included the script, any help would really be appreciated.
Thanks
Theo
include('config.php');
$date = date("d-m-Y" );
$time = time();
$select = "SELECT * FROM " . $pre . "counter WHERE ip = '$ip' AND date = '$date'";
$query = mysql_query($select);
while($l = mysql_fetch_object($query)){
$time2 = $l->time;
if($time2 > $time - $Dtime) $noentry = 1 ;
}
if(!$noentry){
$insert = "INSERT INTO " . $pre . "counter (ip, date, time) VALUES('$ip', '$date', '$time')";
$query = mysql_query($insert) or die(mysql_error());
}
$select = "SELECT * FROM " . $pre . "counter";
$query = mysql_query($select);
$num = mysql_num_rows($query);
$iparray = array();
$i = 0;
while($l = mysql_fetch_object($query)){
$ip2 = $l->ip;
$isin = 0;
$count = count($iparray);
if(!$count) $isin = 0;
for($j = 1; $j < $count + 1; $j++ ){
if($iparray[$j] == "$ip2") $isin = 1;
}
if(!$isin){
$i++;
$iparray[$i] = "$ip2";
}
}
$count = count($iparray);
echo "Hits: " . $num . "<br>";
echo"Unique hits: " . $count;
echo'<br /><a href="image.php">This month\'s chart</a>';
?>
Comment