Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 8 of 8
  1. #1
    New Coder
    Join Date
    Aug 2007
    Posts
    69
    Thanks
    11
    Thanked 2 Times in 2 Posts

    Troobleshooting 500 Internal Error

    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?

  • #2
    New Coder
    Join Date
    Mar 2009
    Location
    Chicago, IL
    Posts
    69
    Thanks
    0
    Thanked 15 Times in 15 Posts
    Check your error logs. If your site is hosted with cpanel, there's an icon for that.

  • #3
    New Coder
    Join Date
    Aug 2007
    Posts
    69
    Thanks
    11
    Thanked 2 Times in 2 Posts
    Nothing in the logs except what page the error was thrown on. There is no .htaccess files on the site either.

  • #4
    Codeasaurus Rex
    Join Date
    Jun 2008
    Location
    Redmond, WA
    Posts
    659
    Thanks
    31
    Thanked 100 Times in 94 Posts
    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.
    Unless otherwise stated, any code posted is most likely untested and may contain syntax errors.
    My posts, comments, code, and suggestions reflect only my personal views.
    Web Portfolio and Code Snippets: http://shanechism.com

  • #5
    Regular Coder
    Join Date
    Mar 2009
    Location
    Troutdale, OR
    Posts
    145
    Thanks
    12
    Thanked 6 Times in 6 Posts
    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.

  • #6
    Super Moderator Inigoesdr's Avatar
    Join Date
    Mar 2007
    Location
    Florida, USA
    Posts
    3,642
    Thanks
    2
    Thanked 405 Times in 397 Posts
    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.

  • #7
    Senior Coder NancyJ's Avatar
    Join Date
    Feb 2005
    Location
    Bradford, UK
    Posts
    3,172
    Thanks
    19
    Thanked 65 Times in 64 Posts
    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)

  • #8
    New Coder
    Join Date
    Aug 2007
    Posts
    69
    Thanks
    11
    Thanked 2 Times in 2 Posts
    Ok, thanks everybody for the help. It looks like it the error is coming from a malformed header. Here is the header

    PHP Code:
    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;



  •  

    Tags for this Thread

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •