I'm making an installer module for my Codeigniter application.
I'm creating the MySQL database and it's tables through code and want to insert user credentials into db during the installation process. Like this:

The problem I'm having is that after creation of database and it's tables, when I try to insert the user info into the database it gives error saying "The table 'user' doesn't exist" while the table actually exists.
Here is the code:
$this->load->dbforge(); //Create the database
$this->install_model->use_sql_string(); //Add the tables from a .sql file
$this->load->database($database_name); //Load the created database
$this->install_model->add_the_user($username, $password)); //Insert user data
The database and tables are being created correctly. Only the last line of code gives the error.
I have no idea what I'm doing wrong here. Please help!
$database_nameand what it has in to it ?$database_namecomes from $_POST (the form) and it's got the name of database the user entered.USE DBName$this->load->database($db_name)does the same thing asUSE DBName