0

how do i configure my php connection file to connect with 2 or more database ?

<?php
if(!isset($_SESSION)) 
    {
session_start();
}
date_default_timezone_set("Asia/Kolkata");
$uid=$_SESSION['user_id'];
$connect['database'] ='mydb';

/** MySQL database username */
$connect['user']='root';
/** MySQL database password */
$connect['password']='';
/** MySQL hostname */
$connect['host']='localhost';
$host= mysqli_connect($connect['host'],$connect['user'],$connect['password'],$connect['database']);
?>
Nigel Ren
  • 56,122
  • 11
  • 43
  • 55
  • You can use `mysqli_connect` for each connection, but you can also access different databases on the same server by prefixing the table names with the database name (assuming the privileges are correct) - something like https://stackoverflow.com/questions/22296500/mysqli-join-tables-from-2-different-databases – Nigel Ren May 30 '21 at 07:14
  • can you configure it for example as i want to connect all tables not a specific one – The Identity May 30 '21 at 07:25
  • It may be better to create an example of what you are trying to achieve and why you are doing it that way. – Nigel Ren May 30 '21 at 07:27
  • I want to login with single php code for to diffrent db , the all db tables are same but have the diffrent data .by this i can save the server space as i am using three code file for the three db but after this implimentation i have to use only one code to a access all three data base. – The Identity May 30 '21 at 07:46

0 Answers0