Hey ppl. I've made an error log function in my "mysql" class which is comprised of writing to files to report an error. The problem is that PHP is throwing an error saying that fputs is getting an argument supplied which is an invalid stream resource.
The function:
function sql_log_error($sql_code, $sql_error, $sql_errno){
$fp = fopen($_SERVER["DOCUMENT_ROOT"]."/logs/mysql.log", "a") || die("<br/>A fatal \"fopen();\" error has occured. Please check back later.");
$sql_mail_success = true;
$sql_mail_message = "An error has occured on the localhost website.\n";
$sql_mail_message .= "Goto the main log file: [url]http://localhost/logs/main.log[/url]";
$send = @mail("evo4ever@phpevo.fsnet.co.uk", "Localhost Script Error!", $sql_mail_message);
if(!$send) $sql_mail_success = false;
$line = "ERROR AT: '".date("d/m/y, H:i:s")."'; IN: '".strtoupper($_SERVER["PHP_SELF"])."'.\n";
$line .= "Message: ".$sql_errno.": \"".$sql_error."\"\n";
$line .= "Code: \"".$sql_code."\"\n";
$line .= "Emailed: ".$sql_mail_success."\n";
$line .= "-----------END-----------\n\n";
fputs($fp, $line) || die("<br/>A fatal \"fputs();\" error has occured. Please check back later.");
fclose($fp);
}
Help appreciated. Thanks.