Well - first I would turn off display errors and turn on log errors. Then - well there is always the error suppressor (@) - but I personally don't like it. You could also create a custom error handler... And I wonder if mysqli supports exceptions... http://www.php.net/manual/en/ref.errorfunc.php http://www.php.net/~helly/php/ext/spl/ Respectfully, Ligaya Turmelle Systems Analyst Guamcell Communications Phone: (671)689-2377 -----Original Message----- From: Richard Morris [mailto:richard@xxxxxxxxxxxxx] Sent: Saturday, January 06, 2007 4:29 AM To: php-general@xxxxxxxxxxxxx Subject: How to suppress error messages when using 'new mysqli(...)' Hi, I am having this problem that I hope can be worked around. I make a connection to our MySQL database using the object version of mysqli. If access is denied because of an incorrect username or password, mysqli displays an error. Is there any way to suppress the error message? Here is the code I am using as a test case: <?php $db = null; $db = new mysqli('localhost', 'user', 'badpass', 'test'); if (mysqli_connect_errno()) { echo "Database connection error.\n\n"; exit(); } echo "Connection successful.\n\n"; ?> This is the output I get: PHP Warning: mysqli::mysqli(): (28000/1045): Access denied for user 'user'@'localhost' (using password: YES) in /home/richard/dbtest.php on line 4 Warning: mysqli::mysqli(): (28000/1045): Access denied for user 'user'@'localhost' (using password: YES) in /home/richard/dbtest.php on line 4 An error occurred while trying to connect to the database. I was expecting this: An error occurred while trying to connect to the database. Is there a way to prevent the error messages from being display so that the error can be handled in a nicer manner? Thank you. -- Richard Morris HDD Broker, Inc. Toll-Free: +1 866 960-3331 International: +1 250 474-6022 Fax: +1 250 474-6099 E-Mail: richard@xxxxxxxxxxxxx Web Site: www.hddbroker.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php