my script doesnt count a reload either... i figured that part out, i dont like flatfile sollutions.
ANyway,
The purpose is to count the total visitors PER day, so at the end of each day is a number shown...
each number is entered in the database with a date as shown in earlier posts and a time in unixformat
Now somehow the reading of the date in the db is screwed so it enters a day lets say january 5 more then one times, resulting in multiple january 5 netries with all one visit....
i think this happend cuz when im in gmt+1 entering a hit then come back an hour later it sees a new day makes a new entry , then someon from gmt-5 enters and stil enters the january 5 but it doesnt match anymore since i entered a januray 6 already so it creates a new one.... this way the db can get fucked over and over resulting in total chaos and unreliable results...
heres the script i made:
$getnumberday="SELECT * FROM bl_counter2";
$getnumberday2=mysql_query($getnumberday) or die("Could not grab todays visit count");
$getnumberday3=mysql_fetch_array($getnumberday2);
$today = date('d-m-Y');
if($getnumberday3[day]!=$today){
$resettodayscount="INSERT INTO bl_counter2 (day, hits) VALUES ('$today','0')";
mysql_query($resettodayscount) or die("Could not reset todays count");
} else {
$newcount=$getnumberday3[hits]+1;
if($getnumberday3[timer]<=$unixtime-3600) {
$updatetodayscount="UPDATE bl_counter2 SET hits='$newcount', timer='$unixtime' WHERE day='$today'";
mysql_query($updatetodayscount) or die("Could not update todays count");
};
};
print "<br>$getnumberday3[hits] <img src='images/today.png' alt='todays visits'> visits today";
the timer field in the db defaults to 0 so its updateable...
db table:
id bigint(21) auto_increment
day varchar(50)
timer bigint(21)
hits (bigint(21)
primary key = id