cbreemer Posted February 26 Share Posted February 26 (edited) Hi Freaks, I am using XMLHttpRequest in my JavaScript code to execute PHP scripts on the server. Works great but one thing puzzles me. Whenever my PHP code triggers a runtime exception (such as a mandatory parameter being empty), the request returns with HTTP status 200 OK. Same happens even when there is a syntax error in my PHP code. Why does it not return a 500 Internal Server error in these cases ? Is there a way to get that behavior without having to check each and every command and explicitly setting a 500 status ? Thanks for any ideas ! Edited February 26 by cbreemer typo Quote Link to comment Share on other sites More sharing options...
Solution mac_gyver Posted February 26 Solution Share Posted February 26 to get php to cause a http 500 status for fatal syntax/runtime errors, php's display_errors setting needs to be set to OFF. you would then want the log_errors setting to be set to ON, so that you have a record of what errors are occurring. also, php's error_reporting needs to always be set to E_ALL or a -1. Quote Link to comment Share on other sites More sharing options...
cbreemer Posted February 26 Author Share Posted February 26 Thanks for that @mac_gyver ! I now remember seeing these tips posted before so I should probably have known. I can't get that to work just now but I'm sure I am doing it wrong and it looks like I first need to study the various error/logging functions in some depth. Meanwhile I'm quite satisfied with my hack, which relies on the observation (fact ?) that PHP error output always starts with <br /> It's a kludge, I know, but for a private hobby project it looks good enough until proven different. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.