View Single Post
Old 08-06-2004, 03:16 PM   #1 (permalink)
bearslife
Registered User
 
Join Date: May 2004
Location: Kellogg, Idaho
Posts: 2
bearslife is on a distinguished road
Re:Inserting and displaying Unique Statistics from users viewing my site, problem

I am trying to figure out how I can insert user information only once
(ip,date,browser,referrer) etc... I don't want to have the user information inserted more than once into my mysql database table. Then I want to display it only once every visitor. I have the scripts working fine right now, but it enters and displays every hit to my site regardless if it is unique or not.

Below is my table in mysql:

CREATE TABLE `statistical` (
`id` int(11) NOT NULL auto_increment,
`ip` varchar(25) NOT NULL default '',
`date` varchar(50) NOT NULL default '',
`subfolder` varchar(65) NOT NULL default '',
`os` varchar(250) NOT NULL default '',
`referrer` varchar(250) NOT NULL default '',
PRIMARY KEY (`id`)
)

Here is my script used to insert the informaiton into the database:
"/astatistic.php"
PHP Code:
<?
$username 
"";
$password "";
$host "";
$database "";
mysql_connect($host,$username,$password) or die("Cannot connect to the database.<br>" mysql_error());
mysql_select_db($database) or die("Cannot select the database.<br>" mysql_error());

$ip $_SERVER['REMOTE_ADDR'];
$date date("D M j g:ia");
$subfolder $_SERVER['PHP_SELF'];
$os $_SERVER['HTTP_USER_AGENT'];
$referrer $_SERVER['HTTP_REFERER'];

$result=mysql_query("INSERT INTO statistical (ip, date, subfolder, os, referrer) VALUES ('$ip','$date','$subfolder','$os','$referrer')")or die("Insert Error: ".mysql_error());

?>
Thanks, and god bless, I really hope that someone can help me figure out how to place the user only oncel into my database and display only that once not five million of the same person stats. Thanks again.

Last edited by bearslife; 07-05-2005 at 07:09 AM. Reason: name change
bearslife is offline   Reply With Quote