Please Help me

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
krdzal
Forum Newbie
Posts: 2
Joined: Sat Aug 30, 2008 12:13 pm

Please Help me

Post by krdzal »

<?php mysql_query("UPDATE game SET hits=hits+1 WHERE id=2 ") or die (mysql_error()); ?>

I have that code on one page ( it is osmething like counter) but when the page load in Firefox
the hits are increasing with 2 instead 1
in IE and Opera it is workin fine
Why?????????????????????????
User avatar
greyhoundcode
Forum Regular
Posts: 613
Joined: Mon Feb 11, 2008 4:22 am

Re: Please Help me

Post by greyhoundcode »

I suggest the answer lies elsewhere - are you using Javascript to control the loading and redirection of pages for example? It sounds as though something [that does not conform to standards] is forcing Firefox to load the pages twice, or perhaps in fact Firefox is doing what it should be doing and the others are ignoring certain instructions?
krdzal
Forum Newbie
Posts: 2
Joined: Sat Aug 30, 2008 12:13 pm

Re: Please Help me

Post by krdzal »

I use javascript but nothing with redirects or something like that. I tryed without javascript and still the same
User avatar
greyhoundcode
Forum Regular
Posts: 613
Joined: Mon Feb 11, 2008 4:22 am

Re: Please Help me

Post by greyhoundcode »

If it's a variant of a counter you are recording then perhaps you could record the IP address and date of each hit and disallow further hits from the same IP on the same day?

Code: Select all

$visitorAddr = $_SERVER['remote_addr'];
$dateVisited = date(zy);
 
if (NewVisitor($visitorAddr, $dateVisited))
{
    $counter++;
}
Where of course NewVisitor() is a function you would write that returns true/false appropriately, and - before it returns a true value - adds the $visitorAddr and $dateVisited to a database table or plain text file, or whatever.
Post Reply