Thread Rating:
  • 1 Vote(s) - 5 Average
  • 1
  • 2
  • 3
  • 4
  • 5

mysqli select db
#1

you can use mysqli_select_db(connection,dbname) with php5+
Here is how :
PHP Code:
<?php
 $connection
=mysqli_connect("localhost","user","password","db");
 
// Check connection error
 
if (mysqli_connect_errno()){
  echo "Failed to connect to MySQL: " mysqli_connect_error();
  }
// change database ;
mysqli_select_db($connection,"test");
mysqli_close($connection);
?>
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
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)