View Full Version : Strange, strange problem! [+rep]
Decode
23-06-2008, 03:46 PM
There is a hit counter on every page of my site, and on firefox i knoticed that when i click a link on my site the hit counter goes up 2 times, I can see the page start to load then get repleaced with the page again (it all happens very fast becuase im viewing it on my localhost). But on internet explorer when you click a link the page only loads once. Allso on firefox once i have visited the page once its fine (it only loads once).
Ive got no javascript on the page or anything like that, its just html and a style sheet, server side theres a mysql database and some of the site info loads from text files. The problem is on every page :(
+Rep if anyone knows how to fix it, or whats causing it. :)
Thanks.
Joshuae
23-06-2008, 03:51 PM
Are you using it on multiple tabs? As, it might be reading the active site connections from the refresh. =P
Decode
23-06-2008, 03:52 PM
Are you using it on multiple tabs? As, it might be reading the active site connections from the refresh. =P
Nope, just 1 tab, and the hit counter goes up by 2 on firefox so its not displaying the the old copy of the page then waiting to recieve the new one.
Jackboy
23-06-2008, 03:54 PM
if u have the counter on 2 pages ie..
index.php has the counter on it, and then lol.php also has counter on it, therefore when lol.php is included in index.php it counts as two.
Decode
23-06-2008, 04:00 PM
if u have the counter on 2 pages ie..
index.php has the counter on it, and then lol.php also has counter on it, therefore when lol.php is included in index.php it counts as two.
This may be the answer. would it count if i was using this?
<html>
<head><title>THIS IS INDEX.PHP</title></head>
<body>
<?php
include("lol.php"); // has hit counter in
?>
</body>
<html>
EDIT: just went to the file that the hit counter is included in and refreshed that on firefox and it still did 2 hits, then i did it on ie and it only did 1. :(
Thanks for your help anyway :P +rep :)
Agnostic Bear
23-06-2008, 04:02 PM
Something is doing the hit counter twice, post the hit counter code and I'll take a look.
Decode
23-06-2008, 04:08 PM
Something is doing the hit counter twice, post the hit counter code and I'll take a look.
Thats the hit counter code, i thought the same as you, but php is server side so i dont understand how it can happen for firefox but no ie.
<?php
$hitcount = "db/hits/" . $pageid . ".txt";
$hits = file_get_contents("$hitcount");
$hits = $hits + 1;
$open = fopen($hitcount , "w");
fputs($open , "$hits");
fclose($open);
echo $hits;
?>
Jack!
23-06-2008, 04:10 PM
im no PHP exper but shout this have +1? $hits = $hits + 1;
Agnostic Bear
23-06-2008, 04:11 PM
Thats the hit counter code, i thought the same as you, but php is server side so i dont understand how it can happen for firefox but no ie.
<?php
$hitcount = "db/hits/" . $pageid . ".txt";
$hits = file_get_contents("$hitcount");
$hits = $hits + 1;
$open = fopen($hitcount , "w");
fputs($open , "$hits");
fclose($open);
echo $hits;
?>
That looks fine to me.
Decode
23-06-2008, 04:11 PM
im no PHP exper but shout this have +1? $hits = $hits + 1;
I dont quite understand what you're saying :S
Decode
23-06-2008, 04:47 PM
That looks fine to me.
Ok :) thanks for helping.
Independent
23-06-2008, 05:31 PM
No 2fast, because it would not have a value then, the value would be +1, just that I think.
Decode
23-06-2008, 05:35 PM
No 2fast, because it would not have a value then, the value would be +1, just that I think.
Lol, i understad what he was trying to say now :P
im no PHP exper but shout this have +1? $hits = $hits + 1;
No becuase it needs to add 1 for the hit counter to go up, and what would be the point in saying $hits = $hits ;)
Independent
23-06-2008, 05:39 PM
Lol, i understad what he was trying to say now :P
No becuase it needs to add 1 for the hit counter to go up, and what would be the point in saying $hits = $hits ;)
Aha, I am correct!
Decode
23-06-2008, 05:45 PM
Well done! +rep :)
Independent
23-06-2008, 05:48 PM
Well done! +rep :)
LOL
Thanks.
Want to hide these adverts? Register an account for free!
Powered by vBulletin® Version 4.2.5 Copyright © 2025 vBulletin Solutions Inc. All rights reserved.