Those Pesky 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
hdweiner
Forum Newbie
Posts: 2
Joined: Sun Apr 11, 2004 4:58 pm

Those Pesky Error Messages

Post 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
User avatar
phice
Moderator
Posts: 1416
Joined: Sat Apr 20, 2002 3:14 pm
Location: Dallas, TX
Contact:

Post by phice »

Looks like your username and password aren't correct.
Image Image
hdweiner
Forum Newbie
Posts: 2
Joined: Sun Apr 11, 2004 4:58 pm

Yes, That's Right

Post 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
qads
DevNet Resident
Posts: 1199
Joined: Tue Apr 23, 2002 10:02 am
Location: Brisbane

Post 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:
User avatar
Ixplodestuff8
Forum Commoner
Posts: 60
Joined: Mon Feb 09, 2004 8:17 pm
Location: Queens, New York

Post 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
Post Reply