Help with file not writing

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



I'm not too good with classes, in the below class I can get the hit counter
to write to the hit counter file, but I can't get it to write the log file,
I know security is done correctly on the file because it's the same as the
counter log file, but I can't figure out why the other file isn't being
written to.
Also while the IP address works within the code prior to calling the class
 
Thanks!
 
<%
class counter {
 var $log_file = 'counters/google_log.txt';
 var $file = 'counters/google_counter.txt'; 
 function counter()
 {
  $this->readFile();
  $this->writeFile();
  $this->writeLog();
 }
 
 function readFile()
 {
  $hiti = fopen($this->file, "r");
  while(!feof($hiti)){
   $this->$hits .= fgets($hiti,128);
  }
  $this->$hits=1+$this->$hits;
  echo $this->$hits;
  fclose($hiti);
 }
 
 function writeFile()
 {
  $hito = fopen($this->file,"w+");
  fputs($hito,$this->$hits);
  fclose($hito);
 }
 
 function writeLog()
 {
  $ip_address=$REMOTE_ADDR;
  $date_stamp=date("F j, Y, g:i a");
   $log_entry=$date_stamp . "  :  " . $ip_address . "\n" ;
   echo "TEST-> " . $log_entry ;
  $log = fopen($this->log_file,"w+");
  fputs($log,$this->$log_entry );
  fclose($log);
 }
 
}
%>

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


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux