• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
[SOLVED] Database Connection Issue -

This is such a newbie issue, but I'm having trouble connecting to my database. I know the information within my database.php file is correct. CI requires you to test out the connection when you install it and I haven't touched the file since. I've tried using autoload.php and manually connecting to the database with long & shorthand. I've quadrupled check the info in my cPanel. I don't get it...

Is there anything else (aside from wrong info in db.php) that could cause the database not to connect? I've copied in what my loader.php file looks like. Is this normal? Assuming it is, just trying to troubleshoot.

Also, my database.php is in my application config and my loader.php is in my system core. I renamed the application/system file folders of course....not sure if I should be updating any filepaths in one of these files. Any ideas of what could be going on?

Thanks in advance!

function database($params = '', $return = FALSE, $active_record = NULL)
        // Grab the super object
        $CI =& get_instance();

        // Do we even need to load the database class?
        if (class_exists('CI_DB') AND $return == FALSE AND $active_record == NULL AND isset($CI->db) AND is_object($CI->db))
            return FALSE;


        if ($return === TRUE)
            return DB($params, $active_record);

        // Initialize the db variable.  Needed to prevent
        // reference errors with some configurations
        $CI->db = '';

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

A bit confused by your post.

first, CI does NOT require you to test out the connection when you install, so not sure what you did.

also, what message(s) are you getting? a generic "could not connect to database", or something else?

try this code in your controller, and see if you have basic info you need, and db permissions:

$con = mysql_connect($host,$username,$password);
if (!$con)
  die('Could not connect: ' . mysql_error());

// some code

Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  

  Theme © 2014 iAndrew  
Powered By MyBB, © 2002-2020 MyBB Group.