PHP mysqli_change_user () function
Examples
Specifies the user to change the database connection:
<? php
$ con = mysqli_connect ( "localhost" , "my_user", "my_password", "my_db");
// Check the connection
if (mysqli_connect_errno ($ con))
{
echo "Database connection failed:" mysqli_connect_error ();.
}
// Switch databases
mysqli_change_user ($ link, "my_user" , "my_password", "my_test");
mysqli_close ($ con);
?>
$ con = mysqli_connect ( "localhost" , "my_user", "my_password", "my_db");
// Check the connection
if (mysqli_connect_errno ($ con))
{
echo "Database connection failed:" mysqli_connect_error ();.
}
// Switch databases
mysqli_change_user ($ link, "my_user" , "my_password", "my_test");
mysqli_close ($ con);
?>
Definition and Usage
mysqli_change_user () function to change the user specified database connection, and set the current database.
grammar
mysqli_change_user( connection,username,password,dbname);
参数 | 描述 |
---|---|
connection | 必需。规定要使用的 MySQL 连接。 |
username | 必需。规定 MySQL 用户名。 |
password | 必需。规定 MySQL 密码。 |
dbname | 必需。规定要改变的新数据库。 |
technical details
return value: | If successful it returns TRUE, on failure returns FALSE. |
---|---|
PHP version: | 5+ |
PHP MySQLi Reference Manual