Welcome Guest, Not a member yet? Register   Sign In
Unable to connect to your database server using the provided settings.
#1

[eluser]Unknown[/eluser]
I'm just starting to work on a project so as to integrate the payment system. So I did not set this up in the beginning..

I'm running this local in Eclipse PDT (Kepler) using the latest Zend server. The whole error is:

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

Configuration
--------------
$db['default']['hostname'] = 'localhost';
$db['default']['username'] = 'userhere';
$db['default']['password'] = 'passwordhere';
$db['default']['database'] = 'dbnamehere';
$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;

System: MacBook Pro, 10.8.5

What I have done:

1) I imported the db via phpMyAdmin and can navigate the local database.
2) I created two scripts testing the connection for both mysql and mysqli using the exact same credentials.

Code:
$connection = mysql_connect('localhost', 'username', 'password');
if (!$connection) {
echo 'Not connected : ' . mysql_error();
}

$db_selected = mysql_select_db('databasename', $connection);

if (!$db_selected) {
echo 'Error connecting : ' . mysql_error()';
} else {
echo 'Success.... Connected......';
}

and...

Code:
$mysqli_connection = new MySQLi('localhost', 'username', 'password', 'databasename');

if ($mysqli_connection->connect_error) {
echo "Not connected, error: " . $mysqli_connection->connect_error;
} else {
echo "Connected.";
}

... both returned "Connected..."

3) I have spent the last hour reading posts here and cross checking every suggested possibility. Even cut and pasted credentials from above scripts to config.
4) I have reviewed the docs on Database Config and any related docs..

No joy...

I'm tapped on this for the moment and need some fresh ideas.. OR... I'm really missing something....

Thanks!!!!
#2

[eluser]Unknown[/eluser]
Found the problem...

As a newbie I had made the assumption that the "database.php" file that needed updating with new credentials was ../system/core/database.php

Apparently not..

I added this code:

Code:
echo '<pre>';
  print_r($db['default']);
  echo '</pre>';
  
  echo 'Connecting to database: ' .$db['default']['database'];
  $dbh=mysql_connect
  (
    $db['default']['hostname'],
    $db['default']['username'],
    $db['default']['password'])
    or die('Cannot connect to the database because: ' . mysql_error());
  mysql_select_db ($db['default']['database']);
  
  echo '<br />   Connected OK:'  ;
  die( 'file: ' .__FILE__ . ' Line: ' .__LINE__);

in the ../system/database/DB.php on line 59, and discovered that my new settings were not being picked up.. So I did a file search and found that "other" location..

../application/config/database.php

and all is working..
#3

[eluser]CroNiX[/eluser]
just a FYI, you should never have to alter anything in /system dir.




Theme © iAndrew 2016 - Forum software by © MyBB