Page 1 of 1
How to see line number instead of 500 error
Posted: Fri Jul 01, 2011 11:55 am
by lostconjugate
Hello,
Does anyone know how to see the line number where the bad syntax is located instead of just getting a 500 error when writing a PHP website? 500 error is not helpful at all in finding my mistakes. Thanks!
Re: How to see line number instead of 500 error
Posted: Fri Jul 01, 2011 12:00 pm
by Jade
Are you using Internet Explorer? Some of the older version of IE use something called User Friendly Errors -- which essentially means you see the 500 page instead of the actual error (WTG Microsoft making things harder to debug is your greatest accomplishment).
You can turn it off by going to options > advanced settings. I believe it's at the bottom or near the bottom.
Re: How to see line number instead of 500 error
Posted: Fri Jul 01, 2011 12:50 pm
by lostconjugate
I tried turning that off and I get the same thing. I also get it in Chrome. I think the user friendly error is one of the 400's, I see it all the time in ASP.NET apps and I can get around it by visiting the website directly on the webserver, that does not work in this case either. The 500 error is "The web page can't be shown"
Re: How to see line number instead of 500 error
Posted: Fri Jul 01, 2011 1:46 pm
by Jade
Are you running PHP on a windows machine? Are you sure it's a PHP error you're getting and not something wrong with the URL or DNS? Can you access the file if you don't have an error?
Re: How to see line number instead of 500 error
Posted: Fri Jul 01, 2011 2:00 pm
by twinedev
500 is a server error, not something like a runtime/syntax error within PHP. (Ie. the server choked, not PHP)
For Apache: If you have access check your error logs. And on a 500 error, it may not be in a site specific error log, but the primary Apache error log.
Re: How to see line number instead of 500 error
Posted: Fri Jul 01, 2011 2:02 pm
by Jade
twinedev wrote:500 is a server error, not something like a runtime/syntax error within PHP.
You can get a 500 server error in IE if you have a syntax error on the page.
Re: How to see line number instead of 500 error
Posted: Fri Jul 01, 2011 3:48 pm
by lostconjugate
Yea it is everytime I type bad syntax, when I finally find it and fix it the 500 error goes away. In the past I stared at it with my debug stare, it looks something like this
Now I have too much code and the debug stare is failing me. My failsafe, which looks like this

, does not work either. Help!
Oh it is Windows Server 2008, IIS7.
Re: How to see line number instead of 500 error
Posted: Fri Jul 01, 2011 6:19 pm
by califdon
Temporarily, while debugging, add these 2 lines at the beginning of your PHP code:
Code: Select all
ini_set("display_errors","2");
ERROR_REPORTING(E_ALL);
Remove them when your script is ready to be placed in production (it could reveal helpful information about your environment to a hacker).
Re: How to see line number instead of 500 error
Posted: Fri Jul 01, 2011 10:57 pm
by McInfo
Re: How to see line number instead of 500 error
Posted: Sat Jul 02, 2011 12:00 am
by califdon
Oops! Thanks for catching that, McInfo. It should be "1". Not sure how I got that.
Re: How to see line number instead of 500 error
Posted: Sat Jul 02, 2011 2:57 am
by Apollo
Jade wrote:You can get a 500 server error in IE if you have a syntax error on the page.
Then it's still not a PHP error, but just something that is outputted by PHP, which IE happens to choke on (i.e. the page was rendered successfully from PHP's point of view).
Re: How to see line number instead of 500 error
Posted: Tue Jul 05, 2011 12:08 pm
by lostconjugate
I tried that display errors setting but nto the error_reporting one, so I tried again still 500. I turned on failed request tracing and here is the error it captured:
ErrorCode The operation completed successfully. (0x0)

Re: How to see line number instead of 500 error
Posted: Tue Jul 05, 2011 8:27 pm
by Benjamin
When debugging on Windows systems, the number should be set to the number of times the system has been restarted in an attempt to make the issue "go away".
Re: How to see line number instead of 500 error
Posted: Tue Jul 05, 2011 10:29 pm
by califdon
Benjamin wrote:
When debugging on Windows systems, the number should be set to the number of times the system has been restarted in an attempt to make the issue "go away".
Awww, Benjamin! LOL
