CodeIgniter Forums

Full Version: Error conecting to external DB
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
I have this error when iI try to connect to external DB:

Severity: Warning --> mysqli::real_connect(): (HY000/2002): Connection refused system/database/drivers/mysqli/mysqli_driver.php 202

I am sure credentials are Ok and if I use this code to check if I can connect:

PHP Code:
$servername "";
$username "username";
$password "password";
$database "database";

// Create connection
$conn mysqli_connect($servername$username$password$database);

// Check connection
if (!$conn) {
    die("Connection failed: " mysqli_connect_error());

"Connected successfully"

I always got "Connected successfully"

This is my configuration:

Quote:$db['mydb'] = array(
'dsn' => '',
'hostname' => '',
'username' => 'username',
'password' => 'password',
'database' => 'database',
'dbdriver' => 'mysqli',
'dbprefix' => '',
'pconnect' => TRUE, // or FALSE doesn't make difference
'db_debug' => '',
'cache_on' => FALSE,
'cachedir' => '',
'char_set' => 'utf8',
'dbcollat' => 'utf8_general_ci',
'swap_pre' => '',
'encrypt' => FALSE,
'compress' => FALSE,
'stricton' => FALSE,
'failover' => array(),
'save_queries' => TRUE

Any advise?
@ rav1971,

Have you looked up the error message? Also, when you said that you always got "Connected successfully" was your PHP and server versions and settings that same between the two systems? Did something change PHP, Mysql versions?