RE: [PHP] Help with file not writing

2005-01-25 Thread Joey
That was it Bret, thanks for pointing out my blindess...

Joey
  

-Original Message-
From: Bret Hughes [mailto:[EMAIL PROTECTED] 
Sent: Wednesday, January 26, 2005 12:34 AM
To: php general list
Subject: Re: [PHP] Help with file not writing

On Tue, 2005-01-25 at 07:53, Joey wrote:
> 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
>  
>  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);
>  

you set $log_entry but write $this->log_entry which does not exist.

try fputs($log,$log_entry );

HTH

Bret

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

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



Re: [PHP] Help with file not writing

2005-01-25 Thread Bret Hughes
On Tue, 2005-01-25 at 07:53, Joey wrote:
> 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
>  
>  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);
>  

you set $log_entry but write $this->log_entry which does not exist.

try fputs($log,$log_entry );

HTH

Bret

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



RE: [PHP] Help with file not writing

2005-01-25 Thread Joey
I Thought I sent a second email that mentioned I did try what you ask and
that didn't make a difference.
Also note the the write to the counter file works perfectly, but the log
file write does not.

Thanks,

Joey
PS No error messages.
  

-Original Message-
From: Richard Lynch [mailto:[EMAIL PROTECTED] 
Sent: Tuesday, January 25, 2005 7:44 PM
To: Joey
Subject: RE: [PHP] Help with file not writing

I'll say it again.

Every place that you have ->$ you should have just ->

It's really that simple.

Honest.

Joey wrote:
> Sorry I forgot to mention that I tried that anyway and no change in 
> the result.
>
> fputs($log,$this->log_entry );
>
>
>
> -Original Message-
> From: Richard Lynch [mailto:[EMAIL PROTECTED]
> Sent: Tuesday, January 25, 2005 1:30 PM
> To: Joey
> Cc: PHP
> Subject: RE: [PHP] Help with file not writing
>
> Joey wrote:
>>  $this->$hits .= fgets($hiti,128);
>
> Do global search and replace for '->$' and change it to '->'
>
>>  $this->$hits=1+$this->$hits;
>>  echo $this->$hits;
>>  fputs($hito,$this->$hits);
>>  fputs($log,$this->$log_entry );
>
> cuz none of those are gonna work.
>
> --
> Like Music?
> http://l-i-e.com/artists.htm
>
> --
> PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: 
> http://www.php.net/unsub.php
>
>


--
Like Music?
http://l-i-e.com/artists.htm

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



RE: [PHP] Help with file not writing

2005-01-25 Thread Joey
Sorry I forgot to mention that I tried that anyway and no change in the
result.

fputs($log,$this->log_entry ); 

 

-Original Message-
From: Richard Lynch [mailto:[EMAIL PROTECTED] 
Sent: Tuesday, January 25, 2005 1:30 PM
To: Joey
Cc: PHP
Subject: RE: [PHP] Help with file not writing

Joey wrote:
>   $this->$hits .= fgets($hiti,128);

Do global search and replace for '->$' and change it to '->'

>   $this->$hits=1+$this->$hits;
>   echo $this->$hits;
>   fputs($hito,$this->$hits);
>   fputs($log,$this->$log_entry );

cuz none of those are gonna work.

--
Like Music?
http://l-i-e.com/artists.htm

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



RE: [PHP] Help with file not writing

2005-01-25 Thread Joey
Actually writing to the counter file works fine, I just can't get it to
write to the log file.

  

-Original Message-
From: Richard Lynch [mailto:[EMAIL PROTECTED] 
Sent: Tuesday, January 25, 2005 1:30 PM
To: Joey
Cc: PHP
Subject: RE: [PHP] Help with file not writing

Joey wrote:
>   $this->$hits .= fgets($hiti,128);

Do global search and replace for '->$' and change it to '->'

>   $this->$hits=1+$this->$hits;
>   echo $this->$hits;
>   fputs($hito,$this->$hits);
>   fputs($log,$this->$log_entry );

cuz none of those are gonna work.

--
Like Music?
http://l-i-e.com/artists.htm

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



RE: [PHP] Help with file not writing

2005-01-25 Thread Richard Lynch
Joey wrote:
>   $this->$hits .= fgets($hiti,128);

Do global search and replace for '->$' and change it to '->'

>   $this->$hits=1+$this->$hits;
>   echo $this->$hits;
>   fputs($hito,$this->$hits);
>   fputs($log,$this->$log_entry );

cuz none of those are gonna work.

-- 
Like Music?
http://l-i-e.com/artists.htm

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



Re: [PHP] Help with file not writing

2005-01-25 Thread Marek Kilimajer
Joey wrote:
 
Hi Marek,
Me? I did not send you anything :)
Member variables in classes are NOT used this way:
$this->$hits
But this way:
$this->hits

I don't see anything in the docs located http://us3.php.net/fopen to help.
I changed it to w only but that made no difference.
Can you please provide a more specific answer.
THanks  

Code looks liks this:
<%
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);
I also think you want just = above (no append)
}
$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=$GLOBALS['HTTP_SERVER_VARS']['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,"a");
		fputs($log,$this->$log_entry );
		fclose($log);
	}
	
}

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


RE: [PHP] Help with file not writing

2005-01-25 Thread Joey
 
Hi Marek,

I don't see anything in the docs located http://us3.php.net/fopen to help.
I changed it to w only but that made no difference.
Can you please provide a more specific answer.

THanks  

Code looks liks this:

<%
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=$GLOBALS['HTTP_SERVER_VARS']['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,"a");
fputs($log,$this->$log_entry );
fclose($log);
}

}

%>

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



[PHP] Help with file not writing

2005-01-25 Thread Joey
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