Jump to content

error_log


robb73

Recommended Posts

Newbie question,

 

I have tried to set up the following custom error log function... (I'm working my way through the Visual Quickpro book on PHP & MySQL)

 

error_log ($message, 1, $email, '[email protected]');

 

...but I never receive the email.

 

I have tested a PHP email form on the server which works - so I'm assuming PHP is set up for email sending.

 

I have also tested the function by sending an error to a .txt file, which works fine.

 

Is there a setting I should be looking at using phpinfo()?

 

Any help much appreciated.

 

Rob

Link to comment
https://forums.phpfreaks.com/topic/44799-error_log/
Share on other sites

Sorry didn't think to post all the code  :-\

 

<?php

 

$live = TRUE;

// Flag variable for site status:

 

// Error log email address:

$email = '[email protected]';

 

// Create the error handler.

function my_error_handler ($e_number, $e_message, $e_file, $e_line, $e_vars) {

 

global $live, $email;

 

// Build the error message.

$message = "An error occurred in script '$e_file' on line $e_line: $e_message\n";

 

// Append $e_vars to the $message.

$message .= print_r ($e_vars, 1);

 

if ($live) { // Don't show the error.

 

// error_log ($message, 3, './err.txt');

error_log ($message, 1, $email, '[email protected]'); // Send email.

echo '<div class="error">An error occurred.</div><br />';

 

} else { // Development (print the error).

echo '<div class="error">' . $message . '</div><br />';

}

 

} // End of my_error_handler() definition.

 

// Use my error handler.

set_error_handler ('my_error_handler');

?>

 

 

Link to comment
https://forums.phpfreaks.com/topic/44799-error_log/#findComment-217524
Share on other sites

I contacted the hosting company and got the following explanation:

 

"Having checked with our engineers I can confirm that the function for emailing the error_log is disabled on the shared hosting servers."

 

Does anyone know if this is usual for shared hosting? Or, as I'm beginning to find

a distinct lack of features with my current provider, should I change my hosting?

My current provider is Fasthosts.

 

Any recommendations appreciated.

 

Rob

Link to comment
https://forums.phpfreaks.com/topic/44799-error_log/#findComment-218184
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.