OP 02 October, 2020 - 06:38 PM
I want to make a multiple database connection based on new users that register in system. Logic is like this: I have a function that connect with main database below:
function db_connect() {
static $connection;
if(!isset($connection)) {
$connection = mysqli_connect('localhost','main_db_user','main_db_pass','main_db_name');
if($connection === false){ return mysqli_connect_error(); }
return $connection;
}
I have created this function inside a file called "conn.php". So, I have created a list with some databases and I want to connect each of them for each new user that is registered in system. In some details: How to change
the connection(to connect with a new database that I have created before) when a new user is registered in the main database?
function db_connect() {
static $connection;
if(!isset($connection)) {
$connection = mysqli_connect('localhost','main_db_user','main_db_pass','main_db_name');
if($connection === false){ return mysqli_connect_error(); }
return $connection;
}
I have created this function inside a file called "conn.php". So, I have created a list with some databases and I want to connect each of them for each new user that is registered in system. In some details: How to change
the connection(to connect with a new database that I have created before) when a new user is registered in the main database?