[PHP] Re: counter freezes whole site!

2003-02-06 Thread Pete
Pag wrote:


Hi, I am having a serious problem on my site. It was working fine 
until a day ago, when it simply freezes. After i made a few checks i 
realized it loops on this code. I tried everything but i cant understand 
why and i am going crazy trying to figure it out!
This code is supposed to write a 24h cookie at first visit, and then 
checks for it at every refresh, if the cookie doesnt exist, it increases 
a counter on the DB. Simple, right? Then why did it stop working out of 
the blue? It loops on the refresh, keeps thinking the cookie is not 
active, so it keeps adding +1 to the counter. What am i doing wrong? How 
can i fix it?
oh, this code is right at the top of my main page.
Thanks!




###


?

 if ($_COOKIE['pvisita'] == '1') {

break;
} else {

include ('databaseinfo.txt');
$ligacao=mysql_connect($h, $u, $p) or die(Erro ao aceder a MySQL);
@mysql_select_db($DBname) or die(Unable to select database  . $DBname);
$resultado = mysql_query (select * from counttable where id='0');

if ($resultado) {
$registo = mysql_fetch_array($resultado);
$id = $registo[ID];
$contador = $registo[contador];
$contador = $contador + 1;
$resultado2 = mysql_query (update counttable set contador='$contador' 
where id='0');
setcookie(pvisita, 1, time() + 86400);
header(Location: .$_COOKIE['pvisita']);


	die; 	// or exit; = same thing



}else{
print (não há registos);
break;
}

}
?






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




[PHP] Re: Counter ?

2002-04-27 Thread Yuri Petro

http://www.hotscripts.com/PHP/Scripts_and_Programs/Counters/Text_Based/

--
Kind regards,
Yuri.

 www.AceHoster.com  Quality web hosting

Cms [EMAIL PROTECTED] ???/ ?  ?:
news:r01050100-0922-9FEB9500593A11D68F37DC65D4C7C8B9@[192.168.0.14]...

 I am looking for a php counter,
 that can do this:
 ___

 Total Visits: 8,585,230
 Visits Today: 2,521

 Today Date: Friday Jan 1, 2002

 __
 And the kicker,
 to have the ability to put this counter, on
 any page, to have it count that page sperate


 Thanks-
 Richard




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




[PHP] Re: counter for HIGH traffic site

2002-04-07 Thread Adam Wan

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




[PHP] Re: Counter

2001-09-25 Thread Chris Lee

there are tutorials all over the inet.

?
  $file_name = '/tmp/counter.txt';
  $counter = fread(fopen($file_name, 'r'), 4096);

  echo $counter;

  unlink($file_name);
  fwrite(fopen($file_name, 'w+'), ++$counter);
?

--

  Chris Lee
  [EMAIL PROTECTED]



Mark Lo [EMAIL PROTECTED] wrote in message
000501c145d9$c5f56ca0$caccfea9@mark">news:000501c145d9$c5f56ca0$caccfea9@mark...
 Hi,

 I would like to know how to write a web page counter in PHP or
 Javascript.

 Thank You

 Mark Lo




-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]