Sometime, when moodle has been installed with Joomlapolis installation scripts, you can get a error: database connection failed message. This is due to the fact that Moodle uses mysqli drivers instead of mysql drivers.
To correct the problem, replace, in the config.php file of moodle
$CFG->dbtype = 'mysql';
$CFG->dbtype = 'mysqli';
This should be sufficient.