i made a script that counts unique visits and user/ip visits the problem is that on my host it counts +2 instead +1 how its written in the script watch and give a reply
mysql database here
here is the link to the script running http://celx.eu/visits.php
Added after 6 minutes:
btw when visiting http://celx.eu/visits.php give 3 or more reloads on page and see how it acts ,,
PHP Code:
<?php
// Your MySQL database host
$db_host = "localhost";
// Your MySQL database username
$db_user = "user";
// Your MySQL database password
$db_pass = "password";
// Your MySQL database name
$db_name = "name";
$conexiune = mysql_connect($db_host,$db_user,$db_pass) or die('I can\'t connect to MySQL server!');
$conexiune1 = mysql_select_db($db_name, $conexiune) or die('Database cannot be found');
//if(!$conexiune1){die("Sorry to many conection it is possible that we are flooded");}
$server=$_SERVER['REMOTE_ADDR'];
$check=mysql_fetch_array(mysql_query("SELECT ipuniq FROM ip_logss WHERE ipuniq='".mysql_real_escape_string($server)."'"));
$cnt=mysql_fetch_array(mysql_query("SELECT total_per_user FROM ip_logss WHERE ipuniq='".mysql_real_escape_string($server)."'"));
$total_per_user=$cnt[0]+1;
if(empty($check[0])){$proc_index=mysql_query("INSERT INTO ip_logss SET ipuniq='".mysql_real_escape_string($server)."'");}
else{$proc_total=mysql_query("UPDATE ip_logss SET total_per_user=".$total_per_user." WHERE ipuniq='".mysql_real_escape_string($server)."' ");}
$check_count = mysql_fetch_array(mysql_query("SELECT COUNT(*) FROM ip_logss"));
echo'<small>ToTal Unique Hits '.$check_count[0].'</small><br/><small>Your visits here '.$cnt[0].'</small><br/>';
?>
mysql database here
Code:
CREATE TABLE IF NOT EXISTS `ip_logss` ( `ipuniq` varchar(500) NOT NULL DEFAULT '', `total_per_user` varchar(500) NOT NULL DEFAULT '', PRIMARY KEY (`ipuniq`) ) ENGINE=MyISAM DEFAULT CHARSET=latin1;
Added after 6 minutes:
btw when visiting http://celx.eu/visits.php give 3 or more reloads on page and see how it acts ,,
Comment