Page 2 of 2

Posted: Sun Jul 21, 2002 1:55 pm
by hex
Sorry to spoil the fun guys, but the last two posts had parse errors! The means protokol wins with the code:

Code: Select all

<?php 
class Counter &#123; 
   function Counter() &#123; // what is a class without a constructor :-) 
   &#125;    

   function checkUniqueVisitor($ip) &#123; 
      $ip = getenv('REMOTE_ADDR'); 
      $_fp = fopen("ips.txt", 'a+'); 
      fclose("$_fp"); 
   &#125; 

   function displayCounter($counter, $prefix='', $suffix='') &#123; 
      if (file_exists($counter)) &#123; 
         $fp = fopen($counter, 'r'); 
         $num = fread($fp, 100); 
         $fpsoma = ($num + 1); 
         fclose($fp); 
         $fa = fopen($counter, 'w'); 
         fwrite($fa, $fpsoma, 100); 
         fclose($fa); 
         echo $prefix.$fpsoma.$suffix; 
         return TRUE; 
      &#125; else &#123; 
         echo ("File not found."); 
         return FALSE; 
      &#125; 
   &#125; 
&#125; 

$oCounter = new Counter; 
$oCounter->displayCounter("counter.txt"); // instantiated object calls the function 

?>
Care to take a serve protokol?

Posted: Sun Jul 21, 2002 4:29 pm
by hob_goblin
i didnt post parse errors, i tried it on my server before posting

$num = "1";
if($num == "1"){
return FALSE; }

works

Posted: Sun Jul 21, 2002 4:52 pm
by protokol
if(in_array($ip,$arr){
return FALSE; }

that's the parse error .. you didn't close off the if() statement

Ok, lemme think of a good one and then i'll serve

Posted: Sun Jul 21, 2002 5:42 pm
by hob_goblin
oh, :-(

man, i thought i was going good too... i always have problems with the multiple )'s