EllisLab text mark
Advanced Search
1 of 2
1
   
Issue: Core/Loader.php -> Db
Posted: 06 January 2012 08:13 AM
Joined: 2012-01-05
7 posts

Hello,

I’m pretty new to codeingiter but I’ve think i’ve manage it pretty well so far. I have this issue which I can’t figure out.

I do get this error upon loading the site:

A Database Error Occurred

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

Filename: core/Loader.php

Line Number: 346

Now, you may think. Ah it’s the database connection strings. But no, it’s not. They are correct.

I checked them out by the debug script made by john_betong

echo '<pre>';
     
print_r($db['default']);
  echo 
'</pre>';

  echo 
'Trying to connect to database: ' .$db['default']['database'];
  
$dbh=mysql_connect
  
(
    
$db['default']['hostname'],
    
$db['default']['username'],
    
$db['default']['password'])
    or die(
'Cannot connect to the database because: ' mysql_error());
    
mysql_select_db ($db['default']['database']);

    echo 
'<br />   Connected OK:'  ;
    die( 
'file: ' .__FILE__ '--> Line: ' .__LINE__); 

I get connected OK.

So on this line 346 I have this code in core/loader.php

// Load the DB class
$CI->db =& DB($params$active_record); 

Anyone?
Many thanks in advance!

 

 
Posted: 10 January 2012 05:57 PM   [ # 1 ]   [ Rating: 0 ]
Joined: 2012-01-05
7 posts

I’ve tried changing $db[‘default’][‘pconnect’] to false.
I have single quotation as mentioned on some other posts regarding database issues.

Anyone?

 
Posted: 10 January 2012 06:34 PM   [ # 2 ]   [ Rating: 0 ]
Avatar
Joined: 2008-11-04
4489 posts

What is the value of:

$db['default']['port'

If not an empty string (”“), it will be appended to the hostname and could cause the connect to fail due to an invalid hostname…

 Signature 

Me: WanWizard.eu | My company: Exite | Datamapper: DataMapper ORM <= LOOKING FOR A NEW MAINTAINER!

 
Posted: 11 January 2012 04:53 AM   [ # 3 ]   [ Rating: 0 ]
Joined: 2012-01-05
7 posts

I don’t have the port setting listed in my database.php by default, but I added it as it should be

$db['default']['port']     '3306'

But no, same error… :/


Also tried from a fresh installation from CodeIngiter 2.1.0 and just changing the database.php and autoloader.php (to load database). Same error.

What could it be?
Here’s the phpinfo http://joacim.me/dev/TEST/phpinfo.php

 
Posted: 11 January 2012 05:33 AM   [ # 4 ]   [ Rating: 2 ]
Avatar
Joined: 2011-03-08
417 posts

Try

1. print_r($params) and print_r($active_record);

2. if the $params are still correct then simplify $active_record

3. echo mysql_error();

4. $db[‘default’][‘db_debug’] = true/false

5. $db[‘default’][‘stricton’] = true/false;
 
 

edit: removed duplicate ‘db_debug’ entry

 Signature 

Ongoing project:
  http://johns-jokes.com/joke-of-the-day/2010/May.html
My Hippy Trail:
  http://the-road-to-kathmandu.johns-jokes.com/
In case you forget:
  http://deformedweb.co.uk/php_variable_tests.php

 
Posted: 11 January 2012 05:48 AM   [ # 5 ]   [ Rating: 2 ]
Joined: 2012-01-05
7 posts

Oh man, thanks!

I think that solved it.

$db[‘default’][‘db_debug’] false 

You are the best person on the planet!

 
Posted: 11 January 2012 10:06 PM   [ # 6 ]   [ Rating: 0 ]
Joined: 2012-01-11
1 posts

i got my problem solved thanks

 
Posted: 24 January 2012 07:08 PM   [ # 7 ]   [ Rating: 0 ]
Joined: 2011-03-17
1 posts

Ok I had the same problem, I was working on my project on a ubuntu/10.4 without complains but when I migrate to Lion OSX, I found this problem. Fixed with db_debug to false, my question is why?

 
Posted: 06 June 2012 04:23 PM   [ # 8 ]   [ Rating: 0 ]
Joined: 2012-03-27
2 posts
patovala - 24 January 2012 07:08 PM

Ok I had the same problem, I was working on my project on a ubuntu/10.4 without complains but when I migrate to Lion OSX, I found this problem. Fixed with db_debug to false, my question is why?


I had this same error when I upgraded to Lion OSX and changing to $db[‘default’][‘db_debug’] = FALSE; fixed this error. Thanks!

 
Posted: 13 August 2012 04:55 PM   [ # 9 ]   [ Rating: 1 ]
Joined: 2012-03-05
1 posts
$db['default']['pconnect'FALSE

i thinks it to false

 
Posted: 07 September 2012 10:03 PM   [ # 10 ]   [ Rating: 0 ]
Joined: 2012-04-26
5 posts

Yes $db[‘default’][‘db_debug’] = false this solved my problem…I was using BigRock hosting….
If somebody would know why? And i was using this value as true on localhost..

 
Posted: 27 October 2012 04:43 AM   [ # 11 ]   [ Rating: 0 ]
Joined: 2012-10-27
1 posts

This post helped me debug my setup, figured I would post my fix to help others.

I am running on Amazon ec2 and was trying to connect to RDS. Turns out I didn’t have my security groups setup. raspberry

 
Posted: 04 November 2012 03:01 PM   [ # 12 ]   [ Rating: 0 ]
Joined: 2012-10-14
1 posts
John_Betong_002 - 11 January 2012 05:33 AM

Try

1. print_r($params) and print_r($active_record);

2. if the $params are still correct then simplify $active_record

3. echo mysql_error();

4. $db[‘default’][‘db_debug’] = true/false

5. $db[‘default’][‘stricton’] = true/false;
 
 

edit: removed duplicate ‘db_debug’ entry


As the others have said

$db['default']['db_debug'FALSE 

solved the same problem which I too was having.

I am interested why is it so    —    that the

$db['default']['db_debug'TRUE 

created the problem ?


It used to run fine on my localhost but had to modify the ‘db_debug’ on the production server.

 
Posted: 04 November 2012 04:42 PM   [ # 13 ]   [ Rating: 0 ]
Joined: 2012-11-02
3 posts

I have the same problem and i tried to change the

$db['default']['db_debug'TRUE 

to

$db['default']['db_debug'FALSE 

but still doesn’t work, can anyone please help me out? plzzzzzzz….downer

 
Posted: 01 December 2012 02:20 AM   [ # 14 ]   [ Rating: 0 ]
Joined: 2012-12-01
1 posts

Same problem. I use print_r($params); but nothing shows…

 
Posted: 04 January 2013 10:24 AM   [ # 15 ]   [ Rating: 0 ]
Joined: 2013-01-04
1 posts

I am getting the same message, but I am only loading a model without a database.
If I change the debug to false, I don’t get the error but it also stops at the line where I load to model.

I am using codeigniter version 2.1.3 on ubuntu 10

 
1 of 2
1