How to see line number instead of 500 error
Moderator: General Moderators
-
lostconjugate
- Forum Newbie
- Posts: 5
- Joined: Tue Dec 07, 2010 3:14 pm
How to see line number instead of 500 error
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!
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
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.
You can turn it off by going to options > advanced settings. I believe it's at the bottom or near the bottom.
-
lostconjugate
- Forum Newbie
- Posts: 5
- Joined: Tue Dec 07, 2010 3:14 pm
Re: How to see line number instead of 500 error
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
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
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.
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
You can get a 500 server error in IE if you have a syntax error on the page.twinedev wrote:500 is a server error, not something like a runtime/syntax error within PHP.
-
lostconjugate
- Forum Newbie
- Posts: 5
- Joined: Tue Dec 07, 2010 3:14 pm
Re: How to see line number instead of 500 error
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.
Now I have too much code and the debug stare is failing me. My failsafe, which looks like this
Oh it is Windows Server 2008, IIS7.
Re: How to see line number instead of 500 error
Temporarily, while debugging, add these 2 lines at the beginning of your PHP code:
Remove them when your script is ready to be placed in production (it could reveal helpful information about your environment to a hacker).
Code: Select all
ini_set("display_errors","2");
ERROR_REPORTING(E_ALL);Re: How to see line number instead of 500 error
"2"?califdon wrote:Code: Select all
ini_set("display_errors","2");
Re: How to see line number instead of 500 error
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
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).Jade wrote:You can get a 500 server error in IE if you have a syntax error on the page.
-
lostconjugate
- Forum Newbie
- Posts: 5
- Joined: Tue Dec 07, 2010 3:14 pm
Re: How to see line number instead of 500 error
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)

ErrorCode The operation completed successfully. (0x0)
Re: How to see line number instead of 500 error
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".McInfo wrote:"2"?califdon wrote:Code: Select all
ini_set("display_errors","2");
Re: How to see line number instead of 500 error
Awww, Benjamin! LOLBenjamin 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".McInfo wrote:"2"?califdon wrote:Code: Select all
ini_set("display_errors","2");