PHP mysqli_change_user() Function

Definition

The mysqli_change_user() function changes the user of the specified database connection, and sets the current database.

Syntax

PHP mysqli_change_user() Function has the following syntax.

mysqli_change_user(connection,username,password,dbname);

Parameter

ParameterIs RequiredDescription
connectionRequired.MySQL connection
usernameRequired.MySQL username
passwordRequired.MySQL password
dbnameRequired.Database to change to

Return

It returns TRUE on success or FALSE on failure.

Example

The following code changes the user of the specified database connection:


<?php/*ww w .  j a v  a2s  .c om*/
$con=mysqli_connect("localhost","my_user","my_password","my_db");

if (mysqli_connect_errno($con)){
  echo "Failed to connect to MySQL: " . mysqli_connect_error();
}
mysqli_change_user($link, "my_user", "my_password", "my_NewUser");

mysqli_close($con);
?>




















Home »
  PHP Tutorial »
    Function reference »




PHP Array Functions
PHP Calendar Functions
PHP Class Functions
PHP Data Type Functions
PHP Date Functions
PHP File Functions
PHP Image Functions
PHP Math Functions
PHP MySQLi Functions
PHP SimpleXML Functions
PHP String Functions
PHP XML Functions
PHP Zip Functions