ExpressionEngine CMS
Open, Free, Amazing

Thread

This is an archived forum and the content is probably no longer relevant, but is provided here for posterity.

The active forums are here.

when I load database library, im getting error....

February 04, 2011 9:11pm

Subscribe [14]
  • #1 / Feb 04, 2011 9:11pm

    reka

    16 posts

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

    here is my error message.. :

    A Database Error Occurred
    
    Unable to connect to your database server using the provided settings.
    
    Filename: core/Loader.php
    
    Line Number: 242
  • #2 / Feb 04, 2011 9:58pm

    Eric Barnes

    487 posts

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

    You should double or triple check those settings.

  • #3 / Feb 04, 2011 10:07pm

    reka

    16 posts

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

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

  • #4 / Feb 05, 2011 4:43am

    cideveloper

    312 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.

  • #5 / Feb 05, 2011 4:58am

    reka

    16 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….

  • #6 / Feb 05, 2011 9:17am

    InsiteFX

    6819 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

  • #7 / Feb 07, 2011 6:30am

    reka

    16 posts

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

  • #8 / Feb 07, 2011 10:38am

    InsiteFX

    6819 posts

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

    InsiteFX

  • #9 / Feb 09, 2011 12:36am

    John_Betong

    690 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><p>‘;</p>
    
    <p>  echo ‘Trying to connect to database: ’ .$db[‘default’][‘database’];<br />
      $dbh=mysql_connect<br />
      (<br />
        $db[‘default’][‘hostname’],<br />
        $db[‘default’][‘username’],<br />
        $db[‘default’][‘password’])<br />
        or die(‘Cannot connect to the database because: ’ . mysql_error());<br />
        mysql_select_db ($db[‘default’][‘database’]);</p>
    
    <p>    echo ‘<br />
       Connected OK:’  ;<br />
        die( ‘file: ’ .__FILE__ . ‘—> Line: ’ .__LINE__);
    </pre>
     
     
     

  • #10 / Feb 09, 2011 4:59am

    Ostemanden

    1 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><p>‘;</p>
    
    <p>  echo ‘Trying to connect to database: ’ .$db[‘default’][‘database’];<br />
      $dbh=mysql_connect<br />
      (<br />
        $db[‘default’][‘hostname’],<br />
        $db[‘default’][‘username’],<br />
        $db[‘default’][‘password’])<br />
        or die(‘Cannot connect to the database because: ’ . mysql_error());<br />
        mysql_select_db ($db[‘default’][‘database’]);</p>
    
    <p>    echo ‘<br />
       Connected OK:’  ;<br />
        die( ‘file: ’ .__FILE__ . ‘—> Line: ’ .__LINE__);
    </pre>
     
     
     

    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 😊

  • #11 / Feb 09, 2011 8:40am

    reka

    16 posts

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

  • #12 / Feb 09, 2011 12:48pm

    InsiteFX

    6819 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

  • #13 / Feb 10, 2011 8:25am

    reka

    16 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


    I’ve change this line…

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


    but, the result is same as before…

  • #14 / Feb 10, 2011 6:15pm

    InsiteFX

    6819 posts

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

    InsiteFX

  • #15 / Feb 15, 2011 7:44am

    reka

    16 posts

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

.(JavaScript must be enabled to view this email address)

ExpressionEngine News!

#eecms, #events, #releases