Today, I just tried to install a sample CodeIgniter project in LAMPP (Ubuntu) machine. I received a following error message in browser, when I try to browse the application.
Message shows some how I am not able to connect to database. I checked the configuration at /opt/lampp/htdocs/doasoil/core/application/config/database.php (path will be different in your case) and everything seems OK to me.
So in order debug the database connection I just added following script at the end of /opt/lampp/htdocs/doasoil/core/application/config/database.php file.
At this time I received the following debug message in browser.
Message: mysql_connect() shows at line 92 of database.php there is some problem. It is not able to find the directory. So I changed,
as
which fix the problem.
Message shows some how I am not able to connect to database. I checked the configuration at /opt/lampp/htdocs/doasoil/core/application/config/database.php (path will be different in your case) and everything seems OK to me.
So in order debug the database connection I just added following script at the end of /opt/lampp/htdocs/doasoil/core/application/config/database.php file.
print_r($db['default']);
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 'Connected OK:' ;
die( 'file: ' .__FILE__ . ' Line: ' .__LINE__);
At this time I received the following debug message in browser.
Message: mysql_connect() shows at line 92 of database.php there is some problem. It is not able to find the directory. So I changed,
$db['default']['hostname'] = 'localhost';
as
$db['default']['hostname'] = '127.0.0.1';
which fix the problem.


0 comments:
Post a Comment