Welcome Guest, Not a member yet? Register   Sign In
Database connection issue
#1

[eluser]Ninjabear[/eluser]
Sorry if this has been covered before, I've searched the forums but I can't find the answer.

I've added my database and can connect via Navicat successfully, but for some reason I keep getting the error,

"A Database Error Occurred Unable to connect to your database server using the provided settings.".

I think my credentials are correct so is there anything else I need to do? I have done the following:

--Database.php--

$active_group = "live";
$active_record = TRUE;

$db['default']['hostname'] = "localhost";
$db['default']['username'] = "root";
$db['default']['password'] = "pass";
$db['default']['database'] = "blog";
$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['live']['hostname'] = "localhost";
$db['live']['username'] = "uname";
$db['live']['password'] = "pass";
$db['live']['database'] = "mydb";
$db['live']['dbdriver'] = "mysql";
$db['live']['dbprefix'] = "";
$db['live']['pconnect'] = TRUE;
$db['live']['db_debug'] = TRUE;
$db['live']['cache_on'] = FALSE;
$db['live']['cachedir'] = "";
$db['live']['char_set'] = "utf8";
$db['live']['dbcollat'] = "utf8_general_ci";

--Autoload--

$autoload['libraries'] = array('session','database','form_validation');
//$autoload['core']=array('database');

--Config.php--

$config['base_url'] = "http://www.danielsportfolio.co.uk/codeigniter/";
#2

[eluser]n0xie[/eluser]
Can you connect with the 'default' active group?
#3

[eluser]Ninjabear[/eluser]
[quote author="n0xie" date="1270428923"]Can you connect with the 'default' active group?[/quote]

No it doesn't work with the default database either (same credentials as live).
#4

[eluser]n0xie[/eluser]
If you are connecting with navicat, are you connecting via 'localhost' or 127.0.0.1 ? Might be you have to connect using 127.0.0.1, depending how you setup your MySQL.
#5

[eluser]Ninjabear[/eluser]
[quote author="n0xie" date="1270429342"]If you are connecting with navicat, are you connecting via 'localhost' or 127.0.0.1 ? Might be you have to connect using 127.0.0.1, depending how you setup your MySQL.[/quote]

I don't think so, because when I do a mysqli_connect() then it connects fine using localhost. It's definitely a Code Igniter issue. I tried 127.0.0.1 anyway but it didn't help. Are there any other Code Igniter settings I should be aware of not mentioned here?
#6

[eluser]n0xie[/eluser]
[quote author="Ninjabear" date="1270429611"]Are there any other Code Igniter settings I should be aware of not mentioned here?[/quote]
Nope this is basically it. I would think it's a typo in the credentials, but I would guess you have verified that several times. I have no idea why it doesn't connect.
#7

[eluser]Ninjabear[/eluser]
The credentials are definitely right. I've had a look through the code igniter code and it doesn't seem to use anything other than a standard connection so I can't see why it wouldn't connect either.
#8

[eluser]Ninjabear[/eluser]
It works! All I did was changed dbdriver to mysqli instead of mysql like this:

$db['live']['dbdriver'] = "mysqli";

Maybe my webhost as stopped supporting oldstyle mysql connections but I don't know why they would.
#9

[eluser]n0xie[/eluser]
I don't know either but I'm glad you got it sorted
#10

[eluser]Unknown[/eluser]
dude I had the same problem as well. It was very frustrating.




Theme © iAndrew 2016 - Forum software by © MyBB