mottwsc Posted August 8, 2009 Share Posted August 8, 2009 I'm forcing an error by purposely leaving out an include file that has db login information in it. When I render the php page, and get to the connection statement $cxn = mysqli_connect($host,$user,$password,$dbname) or die ("Couldn't connect to server.".mysqli_error($cxn)); I get the message 'Couldn't connect to server.' That makes sense. The problem is that I am trying to not have this error display, but instead write the error to a log file that I've specified (which is set up in another directory for security reasons). I have modified the php.ini file so that: error_reporting = E_ALL display_errors = Off log_errors = On error_log = c:/php/log/phplog.txt Unfortunately, I still see the error in the browser and it is not written to the log file. What still needs to be adjusted so that the error is not shown in the browser but is instead written to the log file? Thanks! Quote Link to comment https://forums.phpfreaks.com/topic/169363-solved-trying-to-write-errors-to-a-log-file-instead-of-the-browser/ Share on other sites More sharing options...
wildteen88 Posted August 8, 2009 Share Posted August 8, 2009 Use trigger_error instead. Quote Link to comment https://forums.phpfreaks.com/topic/169363-solved-trying-to-write-errors-to-a-log-file-instead-of-the-browser/#findComment-893645 Share on other sites More sharing options...
mottwsc Posted August 8, 2009 Author Share Posted August 8, 2009 I've tried both trigger_error and error_log, but I get the same result. No custom error is written to either the screen or the log file. Only the generaic error message is written to the screen. Maybe there is something I'm not setting in the ini file? Or maybe I need to use custom error handing with this (although I thought I read that this would work with standard error handling)? Quote Link to comment https://forums.phpfreaks.com/topic/169363-solved-trying-to-write-errors-to-a-log-file-instead-of-the-browser/#findComment-893680 Share on other sites More sharing options...
wildteen88 Posted August 8, 2009 Share Posted August 8, 2009 If display_errors is turned off it shouldn't display any errors. The error will be written to the error log file instead. Are you sure PHP is reading the php.ini you are editing. Confirm this by running the phpinfo() function and looking at the Loaded Configuration File line. Quote Link to comment https://forums.phpfreaks.com/topic/169363-solved-trying-to-write-errors-to-a-log-file-instead-of-the-browser/#findComment-893687 Share on other sites More sharing options...
mottwsc Posted August 8, 2009 Author Share Posted August 8, 2009 There was also a permissions issue for writing the file. I've got it now. Thanks for your help. Quote Link to comment https://forums.phpfreaks.com/topic/169363-solved-trying-to-write-errors-to-a-log-file-instead-of-the-browser/#findComment-893714 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.