unwanted display of error messages

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
mottwsc
Forum Commoner
Posts: 55
Joined: Sun Dec 23, 2007 8:01 pm

unwanted display of error messages

Post by mottwsc »

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

Code: Select all

$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!
mottwsc
Forum Commoner
Posts: 55
Joined: Sun Dec 23, 2007 8:01 pm

Re: unwanted display of error messages

Post by mottwsc »

I tried that specific code, and I still get the generic error message on the screen (not the one in the code), and I don't see anything written to the log file.

Are there other parameters in the ini file that might not be set to allow this to happen?
redmonkey
Forum Regular
Posts: 836
Joined: Thu Dec 18, 2003 3:58 pm

Re: unwanted display of error messages

Post by redmonkey »

Have you tried enclosing the path to the logfile in quotes? I assume you've done the usual sanity checks in that the PHP process has the appropriate permission to write to the file?
User avatar
Eran
DevNet Master
Posts: 3549
Joined: Fri Jan 18, 2008 12:36 am
Location: Israel, ME

Re: unwanted display of error messages

Post by Eran »

did you restart your webserver after making the configuration changes?
mottwsc
Forum Commoner
Posts: 55
Joined: Sun Dec 23, 2007 8:01 pm

SOLVED Re: unwanted display of error messages

Post by mottwsc »

There also was a permissions issue. I was able to get it to work.

Thanks to all.
Post Reply