Web Development Thread, display errors in Coding and Web Development; Major Grrrrrrrrrrrrrrrrrrrrrrrrr
After much time banging my head again the wall over why I keep getting a blank page instead ...
-
12th February 2010, 03:08 PM #1 display errors
Major Grrrrrrrrrrrrrrrrrrrrrrrrr 
After much time banging my head again the wall over why I keep getting a blank page instead of output, I've discovered php now, by default, doesn't show code errors.
ironically now i'm banging my head against the wall over how to get it to show code errors. Apparently just turning display_errors on in php.ini does nothing. :-S
seriously, it really annoys me when what used to be a simple is now a major headache. Good thing ppl are going to the pub after work, I really need a drink!
-
-
IDG Tech News
-
12th February 2010, 03:09 PM #2 Let's be honest - when has a PHP error ever been any use beyond "something is wrong somewhere!" anyway?
Generally being told there was an unexpected character on Line 856 means that I actually missed a semi-colon 200 lines before that
-
-
12th February 2010, 03:10 PM #3 
Originally Posted by
sonofsanta
Let's be honest - when has a PHP error ever been any use beyond "something is wrong somewhere!" anyway?
Generally being told there was an unexpected character on Line 856 means that I actually missed a semi-colon 200 lines before that

I find PHP errors to be quite detailed. If it tells me there's a parse error on a certain line then it's now common sense to look the line before for a semi colon.
-
-
12th February 2010, 03:21 PM #4 My code always has like 20million errors so they were pretty handy, and you do get used to what the more obscure ones tend to mean. I can't code when I don't know what my errors are.
-
-
12th February 2010, 03:22 PM #5 
Originally Posted by
browolf
My code always has like 20million errors so they were pretty handy, and you do get used to what the more obscure ones tend to mean. I can't code when I don't know what my errors are.
Have you set up a custom error handler? This is always the first step I take when coding anything with PHP.
-
-
12th February 2010, 03:27 PM #6 
Originally Posted by
Hightower
Have you set up a custom error handler? This is always the first step I take when coding anything with PHP.
how do you do that ?
similiar to vbscript where you do something along the lines of
Code:
on error goto err:
all your code goes here
err:
response.write error.description
or something along those lines ??
Last edited by mac_shinobi; 12th February 2010 at 03:29 PM.
-
-
13th February 2010, 12:06 PM #7 Create a function in your script:
PHP Code:
function custom_errors($errno, $errstr){
echo "<p>$errno: $errstr</p>";
}
Then make sure you set it within your PHP script:
PHP Code:
set_error_handler(custom_errors);
This allows you to set your errors up to appear how you like. You can wrap it in CSS to make it look pretty etc...
That's a very basic example. I set mine up to show if the site is not live, or show a simple error if site is live and email admin.
-
Thanks to Hightower from:
SHARE: 
Similar Threads
-
By mweller in forum Educational Software
Replies: 1
Last Post: 14th May 2010, 01:17 PM
-
By AntiThesis in forum Windows Server 2000/2003
Replies: 13
Last Post: 19th January 2010, 11:53 AM
-
By karldenton in forum Wireless Networks
Replies: 4
Last Post: 15th June 2009, 12:03 PM
-
By cookie_monster in forum Windows
Replies: 3
Last Post: 18th June 2008, 08:36 PM
-
By tosca925 in forum Windows
Replies: 0
Last Post: 2nd July 2007, 03:27 PM
Thread Information
Users Browsing this Thread
There are currently 1 users browsing this thread. (0 members and 1 guests)
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules