How to disable database error messages on web page in Code Igniter

By default Code Igniter displays the database error message on the web page if there is an error in the SQL statement. This is OK if you are working on a development machine but this should definitely be a cause for concern if this is happening on your production machine as sensitive information related to your database structure and query will be visible to all your visitors and potential hackers.

To stop this from happening please do the following steps:

1. Open the database.php in your application/config folder.
2. Search for db_debug in the file.
3. You will see TRUE against this variable. TRUE will display all your database errors on the web page.
4. You should not set this to FALSE.
5. Upload this file online.

Once uploaded no database errors will be displayed on the web page however they will be logged in your application/logs folder. Either one of the following statements will suffice in your case.

'db_debug' => ((ENVIRONMENT == 'developement') ? TRUE : FALSE),

or

'db_debug' => FALSE,

Hope the above helped.

Please follow and like us:
error

Be the first to comment

Leave a Reply

Your email address will not be published.