Page 1 of 1

Those Pesky Error Messages

Posted: Sun Apr 11, 2004 4:58 pm
by hdweiner
I'm running PHP 4.3 under Windows XP, and I'm new to PHP. Please forgive the newbie question.

I obviously want the interpreter to post parsing errors atop whatever web page is on the screen. But in a production system, I'd rather not have errors, like database connection problems, be displayed. I've written code to catch those errors and I'd like to control the presentation process.

Instead, I'm getting things like this: "Warning: mysql_connect(): Access denied for user: 'ESIAdmin@localhost' (Using password: YES) in C:\Apache\Apache2\htdocs\e-butle.com\PHPScripts\Login02.php on line 54

Warning: mysql_select_db(): supplied argument is not a valid MySQL-Link resource in C:\Apache\Apache2\htdocs\e-butle.com\PHPScripts\Login02.php on line 56"

Is there any way to keep these errors from being displayed?

Thanks.

HDW

Posted: Sun Apr 11, 2004 5:13 pm
by phice
Looks like your username and password aren't correct.

Yes, That's Right

Posted: Sun Apr 11, 2004 5:54 pm
by hdweiner
The user name and password are wrong. I entered them incorrectly to test the program logic I'd developed. Not only did my programming logic catch the error, as it is designed to do, but in addition, I get the PHP error messages--and I don't want them to appear to the user.

HDW

Posted: Sun Apr 11, 2004 6:05 pm
by qads
use @ in front of mysql_connect and mysql_select_db, i.e.

Code: Select all

<?php
@mysql_connect('host', 'username', 'password') or die('cant connect to host...');
?>
you can use it with any function to shut it up :lol:

Posted: Sun Apr 11, 2004 8:05 pm
by Ixplodestuff8
You can do the @ thing for each function, or you can turn off error reporting for everything using this line: error_reporting(0);

Here is the manual page on error reporting