fwrite/fclose troubles

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

 



Hi all,

I've been lurking and reading now for some time, but have decided to
come out of the shadows cause I've got an issue that's gonna drive me crazy!

I'm developing an application and within this application is a class
that is very simple and only serves a singular purpose - to make log
entries to help with debugging. Problem is, now I'm debugging the damned
logging class that is supposed to be helping me debug the application as
I'm putting it together! <sigh> I've looked and looked all over the
place, but I don't seem to be able to find an answer to this problem.
The only information that I have found so far deals with permissions and
I don't think that's the problem. At first I was getting an access
denied error but since setting dir perms and log file perms so that both
apache and my user can right to both the directory and the file that one
has gone away.

Log Directory permissions: /mystuff/logs                  rwx-rwx-rwx (777)
Log file permissions            : /mystuff/logs/run.log   rwx-rwx-rwx
(777)

At any rate, the following is the information I'm getting in the apache
error_log while working on this particular portion of the application:

PHP Warning:  fwrite(): supplied argument is not a valid stream resource
in /mystuff/inc/Log.inc on line 22,
PHP Warning:  fclose(): supplied argument is not a valid stream resource
in /mystuff/inc/Log.inc on line 23,

The Log class:
-----------------------------
class Log{
	public $path, $entry, $logfile;
	
	public function Log(){}
	
	public function setLog($path,$file){
		$this->path = $path;
		$this->logfile = $file;
	}
	
	public function writeLog($entry){
		// open the file, in this case the log file
		$h = "$this->path/$this->logfile";
		fopen($h, 'a+');
		fwrite($h,$entry);
		fclose($h);
	}
}

Code snippet where attempting to write log entry from program:
--------------------------------------------------------------------------------------------
		$pl_log = new Log;
		$pl_log->setLog($logpath,"run.log");
		
		$usernanme = $_POST['username'];
		$password = $_POST['secret'];
		
		/**
	 	  * (debugging)	 logging incoming values from form:
	 	  */
		$pl_log->writeLog("getDateTime(): Incoming values from Login Form:
blah...blah...blah\n");

Any help with this would be most appreciated. (be gentle... I'm a PERL
program learning PHP OOP)

--
Mark

"If you have found a very wise man, then you've found a man that at one
time was an idiot and lived long enough to learn from his own stupidity."
==============================================
Powered by CentOS5 (RHEL5)

--
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