Skip to content

Instantly share code, notes, and snippets.

@dharma017
Last active December 15, 2015 06:58
Show Gist options
  • Save dharma017/49ba988a61daac8749ca to your computer and use it in GitHub Desktop.
Save dharma017/49ba988a61daac8749ca to your computer and use it in GitHub Desktop.
Codeigniter database connection check

Add following code to debug database connection in codeigniter

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

echo 'Trying to connect 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__);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment