i'm trying to connecting my codeigniter framework to external database. But it shows error
A Database Error Occurred Unable to connect to your database server using the provided settings. Filename: core/Loader.php Line Number: 346
then, i insert this one to end of config/database.php
  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__); 
But it shows
A PHP Error was encountered Severity: 8192 Message: mysql_connect(): The mysql extension is deprecated and will be removed in the future: use mysqli or PDO instead Filename: config/database.php Line Number: 79
A PHP Error was encountered Severity: Warning Message: mysql_connect(): Can't connect to MySQL server on '167.114.xxx.xxx' (111) Filename: config/database.php Line Number: 79
Cannot connect to the database because: Can't connect to MySQL server on '167.114.xxx.xxx' (111)
then i trying to create this one outside the codeigniter dir (in public_html)
<?php
$servername = "167.114.xxx.xxx";
$username = "myusername";
$password = "dbpass";
$database = "dbname";
// Create connection
$conn = mysql_connect($servername, $username, $password, $database);
// Check connection
if ($conn->connect_error) {
    die("Connection failed: " . $conn->connect_error);
} 
echo "Connected successfully";
?>
and it shows connected successfully. So, what should i do? while the db details in config/database.php is same with above
 
     
    