EllisLab text mark
Advanced Search
1 of 2
1
   
when I load database library, im getting error….
Posted: 04 February 2011 09:11 PM
Avatar
Joined: 2010-10-19
22 posts

when I load database library, im getting error…. I really dont know how to solve this problem downer downer downer

here is my error message.. :

A Database Error Occurred

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

Filenamecore/Loader.php

Line Number
242 
 
Posted: 04 February 2011 09:58 PM   [ # 1 ]   [ Rating: 0 ]
Avatar
Joined: 2006-12-04
515 posts

That means your connection info is wrong in config/database.php

You should double or triple check those settings.

 Signature 

————————
Eric Barnes | Twitter
————————

 
Posted: 04 February 2011 10:07 PM   [ # 2 ]   [ Rating: 0 ]
Avatar
Joined: 2010-10-19
22 posts

no..im pretty sure that my connection settings are correct… rolleyes
it just happend in my web hosting..

I dont have problems like this before in getcloudigniter.com free web hosting

 
Posted: 05 February 2011 04:43 AM   [ # 3 ]   [ Rating: 0 ]
Avatar
Joined: 2008-11-06
317 posts

who is your new host?

some hosting companies put prefixes in front of database names. Can you show your database config file? blank out the username and password fields.

 
Posted: 05 February 2011 04:58 AM   [ # 4 ]   [ Rating: 0 ]
Avatar
Joined: 2010-10-19
22 posts

here is my database config file :

$active_group 'default';
$active_record TRUE;

$db['default']['hostname''localhost';
$db['default']['username''';
$db['default']['password''';
$db['default']['database''';
$db['default']['dbdriver''mysql';
$db['default']['dbprefix''';
$db['default']['pconnect'TRUE;
$db['default']['db_debug'TRUE;
$db['default']['cache_on'FALSE;
$db['default']['cachedir''';
$db['default']['char_set''utf8';
$db['default']['dbcollat''utf8_general_ci';
$db['default']['swap_pre''';
$db['default']['autoinit'TRUE;
$db['default']['stricton'FALSE


im using default settings from codeigniter…
this problem really make me confused….

 
Posted: 05 February 2011 09:17 AM   [ # 5 ]   [ Rating: 0 ]
Avatar
Joined: 2009-06-19
6707 posts

You can not use the default setting!

You need to fill in the others…

$active_group 'default';
$active_record TRUE;

$db['default']['hostname''localhost';
$db['default']['username''your username';
$db['default']['password''your password';
$db['default']['database''your database name';
$db['default']['dbdriver''mysql';
$db['default']['dbprefix''';
$db['default']['pconnect'TRUE;
$db['default']['db_debug'TRUE;
$db['default']['cache_on'FALSE;
$db['default']['cachedir''';
$db['default']['char_set''utf8';
$db['default']['dbcollat''utf8_general_ci';
$db['default']['swap_pre''';
$db['default']['autoinit'TRUE;
$db['default']['stricton'FALSE

If you do not have a databse then you will need to create one.

InsiteFX

 Signature 

Certified State of CT Computer Programming Teacher.
Custom Designed Icons, eBook Covers Software Boxes. CD, DVD Etc. New iPhone® Tab Bar Icons and iPhone® Applications Icons.

Skype: insitfx

STOP! Before posting your questions, remember the WWW Golden rule:
What did you try? What did you get? What did you expect to get?

Input -> Controller | Processing -> Model | Output -> View

 
Posted: 07 February 2011 06:30 AM   [ # 6 ]   [ Rating: 0 ]
Avatar
Joined: 2010-10-19
22 posts

no, I was setting it correctly, and I’ve made a user and database…
but I still getting error like that….  oh oh
I think the problem is in my webhosting..
but I don’t know correctly..

 
Posted: 07 February 2011 10:38 AM   [ # 7 ]   [ Rating: 0 ]
Avatar
Joined: 2009-06-19
6707 posts

Email your hosting support and ask them what your settings should be.

InsiteFX

 Signature 

Certified State of CT Computer Programming Teacher.
Custom Designed Icons, eBook Covers Software Boxes. CD, DVD Etc. New iPhone® Tab Bar Icons and iPhone® Applications Icons.

Skype: insitfx

STOP! Before posting your questions, remember the WWW Golden rule:
What did you try? What did you get? What did you expect to get?

Input -> Controller | Processing -> Model | Output -> View

 
Posted: 09 February 2011 12:36 AM   [ # 8 ]   [ Rating: 0 ]
Avatar
Joined: 2006-12-26
727 posts

 
 
For debugging Database connection problems I use this script at the end of my ./config/database.php

...
  ...
  ...
  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__); 

 
 
 

 Signature 

Joke of the day - Bulletin Board Ideas     (ongoing development site)

My Hippy Trail    Source code   

Latest Project

 
Posted: 09 February 2011 04:59 AM   [ # 9 ]   [ Rating: 0 ]
Joined: 2010-12-20
1 posts
John_Betong - 09 February 2011 05:36 AM

 
 
For debugging Database connection problems I use this script at the end of my ./config/database.php

...
  ...
  ...
  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__); 

 
 
 

BRILLIANT! I had the same problem connecting to my db - and it was not my first try with CI… But this one, I simply couldnt figure out why it couldnt connect.

With your debugscript, I noticed that I had mixed up the database name and password, and your script told me that it tried to connect to Database: mypassword.

Really good debug script, thank you very much smile

 
Posted: 09 February 2011 08:40 AM   [ # 10 ]   [ Rating: 0 ]
Avatar
Joined: 2010-10-19
22 posts

great script… LOL
so the problem is my web hosting… =_=’

 
Posted: 09 February 2011 12:48 PM   [ # 11 ]   [ Rating: 0 ]
Avatar
Joined: 2009-06-19
6707 posts

Do not forget the bug in MySQL with PHP 5.3

It will not accept localhost for hostname, you have to specify 127.0.0.1

This is a MySQL BUG!

InsiteFX

 Signature 

Certified State of CT Computer Programming Teacher.
Custom Designed Icons, eBook Covers Software Boxes. CD, DVD Etc. New iPhone® Tab Bar Icons and iPhone® Applications Icons.

Skype: insitfx

STOP! Before posting your questions, remember the WWW Golden rule:
What did you try? What did you get? What did you expect to get?

Input -> Controller | Processing -> Model | Output -> View

 
Posted: 10 February 2011 08:25 AM   [ # 12 ]   [ Rating: 0 ]
Avatar
Joined: 2010-10-19
22 posts
InsiteFX - 09 February 2011 05:48 PM

Do not forget the bug in MySQL with PHP 5.3

It will not accept localhost for hostname, you have to specify 127.0.0.1

This is a MySQL BUG!

InsiteFX


I’ve change this line…

$db['default']['hostname''127.0.0.1'


but, the result is same as before…

 
Posted: 10 February 2011 06:15 PM   [ # 13 ]   [ Rating: 0 ]
Avatar
Joined: 2009-06-19
6707 posts

Have you asked your Web Hosting what your settings shoud be?

InsiteFX

 Signature 

Certified State of CT Computer Programming Teacher.
Custom Designed Icons, eBook Covers Software Boxes. CD, DVD Etc. New iPhone® Tab Bar Icons and iPhone® Applications Icons.

Skype: insitfx

STOP! Before posting your questions, remember the WWW Golden rule:
What did you try? What did you get? What did you expect to get?

Input -> Controller | Processing -> Model | Output -> View

 
Posted: 15 February 2011 07:44 AM   [ # 14 ]   [ Rating: 0 ]
Avatar
Joined: 2010-10-19
22 posts

I’ve asked this problem to the admin..
but he said that he still dont know how to resolve this problem… rolleyes rolleyes rolleyes rolleyes

 
Posted: 16 March 2011 09:47 AM   [ # 15 ]   [ Rating: 0 ]
Joined: 2011-02-28
1 posts

If you haven’t solved it yet.. make sure to that you select “localhost” as the host when you create the db-user (if it is localhost).

I noticed that if i didn’t select “localhost”, or basically left it blank, i go the same database error. So changing the host name worked for me.

 
1 of 2
1