SitePoint Sponsor

User Tag List

Results 1 to 9 of 9
  1. #1
    Working on it... Contrid's Avatar
    Join Date
    Apr 2006
    Location
    Online
    Posts
    955
    Mentioned
    2 Post(s)
    Tagged
    0 Thread(s)

    error_reporting Recommendation

    Hi there,

    I'm trying to figure out which error_reporting level/setting I should set in my php.ini file. It is currently set to 0, meaning nothing will be shown.

    I was reading through this :
    http://www.php.net/error_reporting

    The reason why I want to change my error_reporting configuration is because right now, when there is a fatal error in a script on my server, the script simply dies out without any type of notice. It makes development extremely difficult and I'm annoyed to the bone.

    On the php.net site, I read that the default setting is :
    error_reporting(E_ALL ^ E_NOTICE);

    What would you recommend?
    I want all fatal errors to be shown so that I can troubleshoot them. I don't just want my scripts to die out and not show anything, leaving me to guess.

    Yes...I could look at error logs, but the frameworks I work with don't always use the default server error logs and don't always log all errors. I'm not exactly sure why, but I haven't been able to find the errors I was looking for.

    Please help me decide which error_reporting level to put in my php.ini file
    And so I got lost in code...completely asphyxiated by it...

    Premium WordPress plugins - Tribulant Software

  2. #2
    Working on it... Contrid's Avatar
    Join Date
    Apr 2006
    Location
    Online
    Posts
    955
    Mentioned
    2 Post(s)
    Tagged
    0 Thread(s)
    Like just now, I had a simple MySQL error saying :

    Code text:
    Unknown column 'approved' in 'where clause'

    ...and it didn't log it or output the error.
    The script simply died out, leaving me to sniff through my code.
    And so I got lost in code...completely asphyxiated by it...

    Premium WordPress plugins - Tribulant Software

  3. #3
    SitePoint Wizard stereofrog's Avatar
    Join Date
    Apr 2004
    Location
    germany
    Posts
    4,324
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I'd recommend the following settings:

    for development

    error_reporting=E_ALL
    display_errors=1
    log_errors=0

    for production

    error_reporting=E_ALL
    display_errors=0
    log_errors=1
    error_log=/path/to/log/file

  4. #4
    Working on it... Contrid's Avatar
    Join Date
    Apr 2006
    Location
    Online
    Posts
    955
    Mentioned
    2 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by stereofrog View Post
    I'd recommend the following settings:

    for development

    error_reporting=E_ALL
    display_errors=1
    log_errors=0

    for production

    error_reporting=E_ALL
    display_errors=0
    log_errors=1
    error_log=/path/to/log/file
    Thank you for the response.
    For some reason I didn't receive an email notification.

    Anyways...
    I put that into my php.ini file. The first part. (for development). But I still don't see any errors (like the one in my previous post). The script simply dies out. I find this really strange.

    Ah...another thing. My 'display_errors' is not set to 1 or 0. It is set to 'Off'. I set it to 'On', assuming that it would work.

    I'm running a dedicated server with Plesk 8.2. The framework for this specific application is CakePHP. Even with 'debug' set to 2 or 3 for CakePHP, it still doesn't output the errors. Not sure if you're familiar with CakePHP, but I'm just mentioning it in case it might mean something.

    I has to have something to do with my server. Some type of configuration setting preventing errors from being shown. I put the same application on another server running cPanel and it shows the fatal errors. I'm now developing on this server, since it's practically impossible to work on the other one. But still...this cPanel server is not mine. I want to be able to work on my server this way.

    Tell me...how can I set the 'error_reporting' and 'dispay_errors' for a specific domain name? Can I put a php.ini file into the document root of the domain? My domains are currently set up with VirtualHost declarations. Plesk does all of this automatically.

    Please see if you can help me out. If you need any other information, please let me know.
    And so I got lost in code...completely asphyxiated by it...

    Premium WordPress plugins - Tribulant Software

  5. #5
    rajug.replace('Raju Gautam'); bronze trophy Raju Gautam's Avatar
    Join Date
    Oct 2006
    Location
    Kathmandu, Nepal
    Posts
    4,013
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I don't think that you can have such php.ini configuration like apache .htaccess that's why php allows us to override some of the settings from our code itself. Please see error reporting section in php manual there you can have lots of functionalities. Some with ini_set() function and some are with their own way.
    Mistakes are proof that you are trying.....
    ------------------------------------------------------------------------
    PSD to HTML - SlicingArt.com | Personal Blog | ZCE - PHP 5

  6. #6
    Working on it... Contrid's Avatar
    Join Date
    Apr 2006
    Location
    Online
    Posts
    955
    Mentioned
    2 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by rajug View Post
    I don't think that you can have such php.ini configuration like apache .htaccess that's why php allows us to override some of the settings from our code itself. Please see error reporting section in php manual there you can have lots of functionalities. Some with ini_set() function and some are with their own way.
    Yeah...you're right. I don't need to set error_reporting for specific domains actually. But the reason why I was giving it thought is even though I set error_reporting to E_ALL and display_errors to 'On', I still don't see the errors. I spent litterally 5 hours yesterday, trying to figure out why my script was just showing a blank page. It was because a function was undefined. I want to see these errors somehow
    And so I got lost in code...completely asphyxiated by it...

    Premium WordPress plugins - Tribulant Software

  7. #7
    Working on it... Contrid's Avatar
    Join Date
    Apr 2006
    Location
    Online
    Posts
    955
    Mentioned
    2 Post(s)
    Tagged
    0 Thread(s)
    I was googling around and found this :
    http://forums.digitalpoint.com/showthread.php?t=212709

    Safe mode is off on my server and even if I put those two lines at the top of my script, still no errors are shown.

    It is quite frustrating.
    And so I got lost in code...completely asphyxiated by it...

    Premium WordPress plugins - Tribulant Software

  8. #8
    Working on it... Contrid's Avatar
    Join Date
    Apr 2006
    Location
    Online
    Posts
    955
    Mentioned
    2 Post(s)
    Tagged
    0 Thread(s)
    After inserting this :

    Code php:
    error_reporting(8191);
    ini_set('display_errors', 1);

    ...I actually start seeing some things which are helpful.
    I can see the query causing the error.

    But I see many "Strict Standards" errors at the top.
    What integer inside error_reporting() should I use? And at the same time get rid of those strict errors. I'm running php v5.0.4
    And so I got lost in code...completely asphyxiated by it...

    Premium WordPress plugins - Tribulant Software

  9. #9
    SitePoint Wizard silver trophybronze trophy Cups's Avatar
    Join Date
    Oct 2006
    Location
    France, deep rural.
    Posts
    6,869
    Mentioned
    17 Post(s)
    Tagged
    1 Thread(s)

    mysql errors aren't PHP errors

    Quote Originally Posted by Contrid View Post
    Like just now, I had a simple MySQL error saying :

    Code text:
    Unknown column 'approved' in 'where clause'

    ...and it didn't log it or output the error.
    The script simply died out, leaving me to sniff through my code.
    That was a mysql error, and you could be testing for those
    a) when you test your sql before putting it into your script and
    b) you could be testing for the mysql err_no

    The Strict setting in error_reporting() is for helping you identify those differences between PHP4 and PHP5.

    Change the setting if you don't want to see these Strict errors.


Bookmarks

Posting Permissions

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