2

I'm trying to connect to my database but i get the following message:

Unable to connect to your database server using the provided settings.

Filename: core/Loader.php

Line Number: 346

So after reading a lot, I found that setting $db['default']['db_debug'] to FALSE in database connection solves it. I did that and the error message disappeared; the website's first page loaded too but it had no database calls. From then on I started getting errors during my database calls, the query were possibly not returning query objectts.

So I want to know does DB_DEBUG actually solves the problem connection or it simply masks the problem that the DB connection errors do not show?

yash
  • 183
  • 3
  • 12
  • 2
    What framework/library? Looks like codeigniter? http://codeigniter.com/user_guide/database/configuration.html says **db_debug** - *TRUE/FALSE (boolean) - Whether database errors should be displayed.* So I'd lead toward hiding the error instead of fixing it. – Mike B Sep 08 '12 at 03:29
  • yeah it is codeigniter framework – yash Sep 08 '12 at 03:36
  • At least CI 2.0.3 has nothing in that line, what version is it? – Igor Parra Sep 08 '12 at 03:37

3 Answers3

0

I recommend you to set $db['default']['db_debug'] = TRUE while debug Mode.

In Application > Config > database.php set

$db['default']['hostname'] = 'localhost';
$db['default']['username'] = '<ur username>'; // like 'root'
$db['default']['password'] = ',ur pwd.'; // like ''
$db['default']['database'] = '<db name>';

In Application > Config > autoload.php

load the database like,

$autoload['libraries'] = array('database');
Praburam S
  • 155
  • 2
  • 9
0

Please see this, i answered in another question:

I found why. In my situation, database error because my mysql config in php.ini is not right.

CI works well after I set mysql config in php.ini, like this:

[Mysql]
mysql.default_socket = /tmp/mysql.sock

If you didn't configure php.ini, the default socket is /var/mysql/mysql.sock, please check it.

I also set $db['default']['db_debug] to FALSE before, it looks ok, but no. It's just hide the error of mysql config, when I test to read from tables of mysql, I got nothing and didn't know why nothing. So I debug it, i found because my mysql connection was not established. :(

Sheppard Y
  • 101
  • 1
  • 5
0

In Application > Config > database.php set

db['default'] = array(
                 ..,
                'db_debug' => FALSE,
                 ..)
swaroop suthar
  • 632
  • 3
  • 19