Change the user for a specified database connection:
<?php$con = mysqli_connect ( "localhost" , "my_user" , "my_password" , "my_db" ); // Check connection if ( mysqli_connect_errno ( $con )){ echo "Failed to connect to database: " . mysqli_connect_error (); } //Switch database mysqli_change_user ( $link , "my_user" , "my_password" , "my_test" ); mysqli_close ( $con ); ?>The mysqli_change_user() function changes the user for the specified database connection and sets the current database.
mysqli_change_user( connection,username,password,dbname);
parameter | describe |
---|---|
connection | Required. Specifies the MySQL connection to use. |
username | Required. Specifies the MySQL username. |
password | Required. Specifies the MySQL password. |
dbname | Required. Specifies the new database to be changed. |
Return value: | Returns TRUE if successful and FALSE if failed. |
---|---|
PHP version: | 5+ |