View Full Version : Troobleshooting 500 Internal Error

03-28-2009, 07:23 PM
Hi, I am trying to troobleshoot a php app that has a coupe of pages that throw 500 internal errors. Any best practices on how to do this or common problems that would cause this?

03-28-2009, 07:35 PM
Check your error logs. If your site is hosted with cpanel, there's an icon for that.

03-28-2009, 11:09 PM
Nothing in the logs except what page the error was thrown on. There is no .htaccess files on the site either.

03-29-2009, 12:33 AM
To my knowledge PHP doesn't really cause 500 errors. It probably can happen, just in all the time I've been coding it it never has.

I've always had my problems with 500 errors when screwing with .htaccess. Alternatively, there could a problem in the php.ini if you have one, or if you did a PHP ini function in your script that could cause it as well.

03-29-2009, 05:31 AM
Very weird. PHP should not cause this error unless its related to the .htaccesss somehow.
Try renaming your .htaccess file to backup.htaccess and it might show the script error instead of showing you 500 error.

03-29-2009, 09:23 PM
500 errors can be caused my a module failing to load, or a configuration error(ie. missing/malformed php.ini). If you have configured this manually you need to check the server logs for more information, and if you are on a shared server you need to contact your host.

03-29-2009, 10:57 PM
I've seen this when PHP is running as CGI (eg. FastCGI) rather than an apache module but it did give further info in the error log. In this case the script ran properly but the server returned a 500 error (Premature end of script headers)

03-30-2009, 08:05 PM
Ok, thanks everybody for the help. It looks like it the error is coming from a malformed header. Here is the header

function sendMail($_firstname, $_lastname, $_email, $message) {
$headers = "From: My Site Name\n";
$headers .= "X-Mailer: PHP\n";
$subject = "Welcome to My site name";
$recipient = "$_firstname, $_lastname <$toEmail>";
$response = mail($recipient, "$subject", $message, $headers);
return $response;