Welcome Guest, Not a member yet? Register   Sign In
Hidden database errors
#1

[eluser]Unknown[/eluser]
Ok, so I configure my login permissions in the database.php like a good boy... Except I make a typo in the username field. I expect a huge "kaboom!" the first time I try to access my database. I expect CI to yell and scream that the DB login failed and my subsequent query to also yell and scream, if the code ever gets to that point.

Exceptions will be thrown; error values will be returned from function calls; I, as the programmer, will be publicly humiliated and egged.

Instead what I get is a silenced error, and the whole query insert code runs happily. If I happen to have CI logging turned off in config.php, then there is absolutely no way for me to know that there is something wrong with my DB login config.

Is this how CI is supposed to work, or am I being a n00b at this and I should beat myself on the head for doing something stupid?

What I want is for CI to yell and scream about any error. The absolute worst thing to do is to move happily along as if nothing had gone wrong.

BTW, I have db_debug turned on in database.php:

Code:
$db['default']['db_debug'] = TRUE;

In the resulting log I get this when there is a credentials typo:

Code:
ERROR - 2012-03-01 06:57:13 --&gt; Severity: Warning  --&gt; mysql_pconnect() [<a href='function.mysql-pconnect'>function.mysql-pconnect</a>]: Access denied for user 'XXXXX'@'localhost' (using password: YES) /root_path_here/system/database/drivers/mysql/mysql_driver.php 91
ERROR - 2012-03-01 06:57:13 --&gt; Unable to connect to the database

And what's this about "Severity: Warning"??? I want ANY database error to be "Severity: End of the world, stop immediately"

Is there any way to get CI to treat database access as, you know, important? Am I just doign something wrong and being a n00b about this?

Thanks :-)
#2

[eluser]w1n78[/eluser]
try these 2 things

1. in your controller, you can use
Code:
$this->output->enable_profiler(TRUE);
http://ellislab.com/codeigniter/user-gui...iling.html

2. check the index.php file. if your environment is set to development, it should display all errors
Code:
error_reporting(E_ALL);
#3

[eluser]Unknown[/eluser]
Thanks!

I had development environment enabled (it's probably on by default?)...

I think I just have to dig into the code a little more: There seems to be no reference material for the DB access method prototypes (so no easy way to know if they return FALSE if error, etc... and they do not throw exceptions upon error, so I need to look at the code.

I may end up writing my own DB access layer, this hiding of errors is a complete and absolute deal killer for me. Under no circumstances should DB errors be ignored or hidden ever (for my app anyway).

Thanks!
#4

[eluser]Matalina[/eluser]
Your server could be suppressing all error messages regardless. You can fix that with:

Code:
ini_set('display_errors', 1);
ini_set('log_errors', 1);
ini_set('error_log', dirname(__FILE__) . '/error_log.txt');
error_reporting(E_ALL);

replacing error_report(E_ALL) in the index.php file.

I have to do this as my server does it by default.




Theme © iAndrew 2016 - Forum software by © MyBB