a2bardeals Posted December 15, 2006 Share Posted December 15, 2006 i am writing a stat cruncher for my site and i have a simple script:[code]<?php$con1 = mysql_connect("localhost","LOGIN", "PASSWORD");$domain = GetHostByName($REMOTE_ADDR); $browser = $_SERVER['HTTP_USER_AGENT'];$page = $_SERVER['SCRIPT_NAME'];mysql_select_db("stats", $con1);$sql44="INSERT INTO `visitors` ( `IP` , `BROWSER` , `PAGE`, `TIME`)VALUES ('$domain', '$browser', '$page', NOW() );";if (!mysql_query($sql44,$con1)) { die('Error: ' . mysql_error()); }?>[/code]of course for sanity i have this page called getinfo.php and use it as an include on different pages i want to track. So say on my index page i have <?php include "getinfo.php"; ?>now here's the problem....when i load the index page it inserts the data multiple times. It's not at all consistant with how many it will insert 1,2,3,4 up to 5. The TIME column is a TIMESTAMP in MySQL format and is also the primary index for the table. What's weird is it works fine if you only load getinfo.php by itself and not as an include. I have tried this include in both the head and body and produces the same result. Any Ideas would be very much appreciated! Quote Link to comment Share on other sites More sharing options...
btherl Posted December 15, 2006 Share Posted December 15, 2006 My gut feeling is that you have an include loop. If you aren't already, try using include_once() instead of include().Another idea is to print something out at the start of each of your files. Then you can see in what order which file is run. It basically gives you a trace of what was included where. Alternatively you can put this data into a global array, and print it out later. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.