On 19 Mar 2008, at 23:38, Mark Weaver wrote:
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);
}
}
RTFM. The fopen function (http://php.net/fopen) will return a stream
resource. The fwrite (http://php.net/fwrite) and fclose (http://php.net/fclose
- noticing a pattern here?) take that resource as the first
parameter. You're passing the filename to those functions, which as
the error messages clearly state is not a valid stream resource.
Please RTFM carefully before asking here, it'll help save both our
sanity and yours!
-Stut
--
http://stut.net/
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php