grahamgr3 Posted December 22, 2014 Share Posted December 22, 2014 I am using a live site and the error message shouldn't be displayed on my website but it is. I don't know why. The error message it shows online is Could not connect to MySQL: Access denied for user 'moreaw32_grah2'@'localhost' (using password: YES) . When other errors occur on my site it does not show the detailed message. I don't want it to show the details of my database like my user name which it does show. Here is the line of code in my connection script. $dbc = @mysqli_connect (DB_HOST, DB_USER, DB_PASSWORD, DB_NAME) OR die ('Could not connect to MySQL: ' . mysqli_connect_error()) What can I do to prevent this. Link to comment Share on other sites More sharing options...
Necuima Posted January 29, 2015 Share Posted January 29, 2015 Hi, in Larry's book PHP Advanced and OO Programming, there is a great structure set out which covers this in chapter 2. I think that it is also in the PHP5 Advanced book too. In a nutshell, his modularised approach includes a config.inc.php module which sets up some constants and variables, one of which indicates whether you are running in a development environment or a production environment. This variable ($local) is a Boolean which is set to either true or false. When an error message is to be displayed, a test is made against this Boolean so you can vary the message displayed accordingly. Hope it helps. Cheers. Link to comment Share on other sites More sharing options...
Recommended Posts