Re: counter for HIGH traffic site

From: Date: Sun, 07 Apr 2002 10:51:51 +0000
Subject: Re: counter for HIGH traffic site
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-91917@lists.php.net to get a copy of this message
"Craig Westerman" <westerman@chanuteks.com> wrote in message news:DEECKMLOFODOLNHCJBFPGEPNEFAA.westerman@chanuteks.com... > 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 ><> > westerman@chanuteks.com > 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

« previous php.general (#91917) next »