"Craig Westerman" <[EMAIL PROTECTED]> wrote in message
[EMAIL PROTECTED]">news:[EMAIL PROTECTED]...
> I'm needing counter for site that receives 60 to 80 hits a minute. Many I
> have tried cause excessive server load and need to be deactivated or they
> lose data and return to zero without warning. All tried so far have been
> written in Perl.
>
> Anyone here know of a PHP counter that would handle HIGH traffic with
little
> added server load? Would using MySQL to store count be of any benifit?
>
> Thanks
>
> Craig ><>
> [EMAIL PROTECTED]
>

Make a mysql table that looks like this

tablename: mysqlcount
columns: "id" and "count"


Then add a single entry with "id" set to 1 and count set to 0, or whatever
your count was before.

Then use this code in your page.

$str = 'http://www.yourdomain.com/where/this/is/located'.$PHP_SELF;
if ( $str != $HTTP_REFERER ) {
mysql_query("UPDATE mysqlcount SET count=count+1 WHERE id=1");
}
$count_query = @mysql_query("SELECT count FROM mysqlcount WHERE id=1");
echo substr(@mysql_result($count_query,0),
0, -3).','.substr(@mysql_result($count_query,0), -3);

that should be pretty fast.

-Adam



-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to