Forum Moderators: coopster
To be exact, the site is running in a subdomain and I want to write the errors to a file in the subdomain route.
My problem is that if I use...
error_log($msg, 3, "/sql_remote_error_log.log") when the script that causes the error is not in the root directory, eg. '/docs/bad_script.php' the error is written to the '/docs/' directory instead. I wouldn't mind but I have lots of directories and it's getting really tedious trying to check all the logs!
The error function is only referenced by the bad_script.php, I can't type the full path in my function because if I do it will be incorrect when accessed from other locations.
I also tried specifying an absolute path from 'http://..' but it failed with an error (something about http wrapper does not support writable connections.
Is there an easy way around this please?
Regards, peter
"Warning: fopen(http://mydomain.ph/sql_remote_error_log.log) [function.fopen]: failed to open stream: HTTP wrapper does not support writeable connections. in /usr/home/mydomain/domains/mydomain.ph/public_html/functions/common_funcs.php on line 46
Cannot open error log."
Here is the code I used:
// begin write to file
$filename = 'http://mydomain.ph/sql_remote_error_log.log';
// We're opening $filename in append mode.
if (!$handle = fopen($filename, 'a+b')) {
echo "Cannot open error log.";
exit;
}
// Write $msg to our opened file.
if (fwrite($handle, $msg) === FALSE) {
echo "Cannot write to error log.";
exit;
}
fclose($handle);
// end write to file
The example in the manual uses an http path, so I can't understand why this is failing?
Any ideas pls?
PHP5, by the way.
pete