Welcome Guest, Not a member yet? Register   Sign In
Db connects with mysql_connect but not database autoload
#1

[eluser]CJL01[/eluser]
I'm struggling with a problem that should be really basic... I've got a fresh copy of CI 1.7, and I'm trying to simply connect to a MySQL database.

If, in my default controller I add;

Code:
$dbh=mysql_connect ("localhost", "my_user","my_password") or die('Cannot connect);
mysql_select_db ("my_database");

Then everything is fine - no errors. If, however, I put exactly the same config details in config/database.php, and then autoload the database helper, I get a database connection error.

Code:
$active_group = "default";
$active_record = TRUE;
$db['default']['hostname'] = "localhost";
$db['default']['username'] = "my_user";
$db['default']['password'] = "my_password";
$db['default']['database'] = "my_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";

I must be doing something really stupid because this has to be CI lesson 1...


Messages In This Thread
Db connects with mysql_connect but not database autoload - by El Forum - 06-02-2009, 08:39 PM



Theme © iAndrew 2016 - Forum software by © MyBB