PHP Tennis

Ye' old general discussion board. Basically, for everything that isn't covered elsewhere. Come here to shoot the breeze, shoot your mouth off, or whatever suits your fancy.
This forum is not for asking programming related questions.

Moderator: General Moderators

User avatar
hex
Forum Commoner
Posts: 92
Joined: Sat Apr 20, 2002 3:20 am
Location: UK

Post 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?
User avatar
hob_goblin
Forum Regular
Posts: 978
Joined: Sun Apr 28, 2002 9:53 pm
Contact:

Post by hob_goblin »

i didnt post parse errors, i tried it on my server before posting

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

works
User avatar
protokol
Forum Contributor
Posts: 353
Joined: Fri Jun 21, 2002 7:00 pm
Location: Cleveland, OH
Contact:

Post 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
User avatar
hob_goblin
Forum Regular
Posts: 978
Joined: Sun Apr 28, 2002 9:53 pm
Contact:

Post by hob_goblin »

oh, :-(

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