Codeigniter Can't Connect to External SQL Server <p>i'm trying to connecting my codeigniter framework to external database. But it shows error</p> <blockquote> <p>A Database Error Occurred Unable to connect to your database server using the provided settings. Filename: core/Loader.php Line Number: 346</p> </blockquote> <p>then, i insert this one to end of config/database.php</p> <pre><code> echo '&lt;pre&gt;'; print_r($db['default']); echo '&lt;/pre&gt;'; 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 '&lt;br /&gt; Connected OK:' ; die( 'file: ' .__FILE__ . ' Line: ' .__LINE__); </code></pre> <p>But it shows </p> <blockquote> <p>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</p> <p>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</p> <p>Cannot connect to the database because: Can't connect to MySQL server on '167.114.xxx.xxx' (111)</p> </blockquote> <p>then i trying to create this one outside the codeigniter dir (in public_html)</p> <pre><code>&lt;?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-&gt;connect_error) { die("Connection failed: " . $conn-&gt;connect_error); } echo "Connected successfully"; ?&gt; </code></pre> <p>and it shows connected successfully. So, what should i do? while the db details in config/database.php is same with above</p>