Jump to content

mysql_connect() problem


robert_gsfame

Recommended Posts

mysql_connect("$host", "$username", "$password")or die("cannot connect to server");

 

i create a connection and let say there is a problem with the server so that the connection can't established

 

my question is how can i avoid the default error to be displayed which is

 

WARNING: mysql_connect() blablabla

 

as it is annoying to see such error message.

 

thx in advance

Link to comment
Share on other sites

In a development environment you want those errors, so that you can spot them instantly and fix them. On a production environment however, you should have all error messages disabled anyway. If possible this should be set within the server's php.ini configuration file, but if not you can set it from within the code:

 

ini_set('display_errors', 0);

Link to comment
Share on other sites

error_reporting() should still be enabled, albeit at a much higher level (fatal errors only), so that the server's error log still gets them. That way if users start reporting issues with the site, you can show them a "Sorry we're having technical difficulties" type error, but then look-up the actual error in the log. Best scenario would be also to get an email when ever a fatal error is triggered. Of course you don't want this on DEV, you just want all errors displayed instantly.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.