CodeIgniter Forums
Unable to connect to your database server using the provided settings. Filename: core/Loader.php Line Number: 346 - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20)
+--- Forum: Archived Development & Programming (https://forum.codeigniter.com/forumdisplay.php?fid=23)
+--- Thread: Unable to connect to your database server using the provided settings. Filename: core/Loader.php Line Number: 346 (/showthread.php?tid=60976)



Unable to connect to your database server using the provided settings. Filename: core/Loader.php Line Number: 346 - El Forum - 08-17-2014

[eluser]Unknown[/eluser]
Hi im new in the forum.

I've readed all the solutions i found on this issue yet no one worked for me so far.

Every time i try to connect to de db i see this error:

Quote:A Database Error Occurred

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

Filename: core/Loader.php

Line Number: 346

This is my database.php config:

Code:
$active_group = 'default';
$active_record = TRUE;

$db['default']['hostname'] = 'localhost';
$db['default']['username'] = 'p6000115_user';
$db['default']['password'] = 'mypassword';
$db['default']['database'] = 'p6000115_bigplan';
$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;

I've tryed to connect without using ci with this code:

Code:
echo '<pre>';
print_r($db['default']);
echo '</pre>';

$link = mysqli_connect($db['default']['hostname'],$db['default']['username'],$db['default']['password'],$db['default']['database']) or die("Error " . mysqli_error($link));
echo 'Conecte';
die();

When i do this it connects to the db.

Following another post here i've dissabled the db_debug param. It didn't show the error but when i try to access the db it's not there so it isn't connected.

I've tryied also to change DB_driver.php where it says :

Code:
$this->display_error('db_unable_to_connect');

I've changed it to:

Code:
die(mysqli_connect_error());
$this->display_error('db_unable_to_connect');

It only shows a blank page, no error. I don't know what to do anymore.

Thanks in advance.




Unable to connect to your database server using the provided settings. Filename: core/Loader.php Line Number: 346 - El Forum - 08-17-2014

[eluser]CroNiX[/eluser]
Your test code is using the MySQLi driver. Did you try using that for CI? It's using regular (deprecated) mysql driver (dbdriver).


Unable to connect to your database server using the provided settings. Filename: core/Loader.php Line Number: 346 - El Forum - 08-18-2014

[eluser]stevezissou[/eluser]
To add what CroNiX said, you also have persistent connections enabled in datatabase.php (which would use mysql_pconnect()).


Unable to connect to your database server using the provided settings. Filename: core/Loader.php Line Number: 346 - El Forum - 08-19-2014

[eluser]InsiteFX[/eluser]
Test database, create a new php file in your root

Code:
&lt;?php

$db_conn = mysqli_connect("localhost", "user_name", "password", "database_name");

// Evaluate the connection
if (mysqli_connect_errno())
{
    echo mysqli_connect_error();
    exit();
}
else
{
    echo "Successful database connection, happy coding!!!";
}

?&gt;

I use MySQLi with pconnect and it works fine on my system.



Unable to connect to your database server using the provided settings. Filename: core/Loader.php Line Number: 346 - El Forum - 08-19-2014

[eluser]CroNiX[/eluser]
He said he already did that in the first post and it worked. Not sure why you're suggesting he try again.


Unable to connect to your database server using the provided settings. Filename: core/Loader.php Line Number: 346 - El Forum - 08-20-2014

[eluser]Unknown[/eluser]
[quote author="CroNiX" date="1408301585"]Your test code is using the MySQLi driver. Did you try using that for CI? It's using regular (deprecated) mysql driver (dbdriver).[/quote]

Thank you very much, i've just change the param dbdriver and it wotks perfect. :lol:

This is my final database.php file just in case someone is having the same issue.

Code:
$active_group = 'default';
$active_record = TRUE;

$db['default']['hostname'] = 'localhost';
$db['default']['username'] = 'root';
$db['default']['password'] = 'Lugones24';
$db['default']['database'] = 'bigplan';
$db['default']['dbdriver'] = 'mysqli';
$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;