mysqli select db - Printable Version

+- WebToTell (https://www.webtotell.com)
+-- Forum: PHP for beginners and advance users.PHP Code samples, applications. (https://www.webtotell.com/Forum-PHP-for-beginners-and-advance-users-PHP-Code-samples-applications)
+--- Forum: PHP (https://www.webtotell.com/Forum-PHP)
+---- Forum: MySQL Database (MariaDB) (https://www.webtotell.com/Forum-MySQL-Database-MariaDB)
+---- Thread: mysqli select db (/Thread-mysqli-select-db)

mysqli select db - turgam - 03-27-2019

you can use mysqli_select_db(connection,dbname) with php5+
Here is how :
PHP Code:
// Check connection error
if (mysqli_connect_errno()){
  echo "Failed to connect to MySQL: " mysqli_connect_error();
// change database ;
Here is the catch: you have to have same privileges in both database in mysql in order to change database with same username, 
If you want to use separate connection for both database please see the post
Multiple MySQLi DataBase connections for mysqli with PHP