We help IT Professionals succeed at work.
Get Started

PHP error function not working on AWS

Torquil Beavis
Last Modified: 2017-02-26
I have successfully used this PHP error handler on a remote shared Linux server developing with PHP & MySQL. Since moving development to AWS EC2 EBS RDS with VPC and CloudFront on Linux, whenever an error occurs no error message shows; the script simply fails. In one case a blank page showed, and in another case the POST submit was negated.
Any ideas on how to make the errors show?
function my_error_handler ($e_number, $e_message, $e_file, $e_line, $e_vars)
	// Build the error message.
	$err_message = "<p>Error '$e_number' \n<br> occurred in script '$e_file' on line $e_line:\n<br> $e_message\n<br> with '$e_vars'\n<br>";

	// Add the date and time:
	$err_message .= "Date/Time: " . date('j-n-Y H:i:s') . "\n<br>";

	if (!LIVE)
		echo '<div class="error">' . $err_message . '</div><br>';
                // Don't show the error

		// Send an email to the admin:
		mail(EMAIL, 'nm error from error handler in nm-config.inc.php', $err_message, 'From: '.EMAIL);

		// Only print an error message if the error isn't a notice:
		if ($e_number != E_NOTICE)
			echo '<div class="error">A system error occurred. We are working like crazy to fix this ;) We apologize for the inconvenience.</div><br>';

set_error_handler ('my_error_handler');

Open in new window

Watch Question
Most Valuable Expert 2011
Author of the Year 2014
This problem has been solved!
Unlock 1 Answer and 10 Comments.
See Answer
Why Experts Exchange?

Experts Exchange always has the answer, or at the least points me in the correct direction! It is like having another employee that is extremely experienced.

Jim Murphy
Programmer at Smart IT Solutions

When asked, what has been your best career decision?

Deciding to stick with EE.

Mohamed Asif
Technical Department Head

Being involved with EE helped me to grow personally and professionally.

Carl Webster
CTP, Sr Infrastructure Consultant
Ask ANY Question

Connect with Certified Experts to gain insight and support on specific technology challenges including:

  • Troubleshooting
  • Research
  • Professional Opinions
Did You Know?

We've partnered with two important charities to provide clean water and computer science education to those who need it most. READ MORE