PHP mysqli_change_user() Function
In this chapter you will learn:
- Definition for PHP mysqli_change_user() Function
- Syntax for PHP mysqli_change_user() Function
- Parameter for PHP mysqli_change_user() Function
- Return for PHP mysqli_change_user() Function
- Example - changes the user of the specified database connection
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
Parameter | Is Required | Description |
---|---|---|
connection | Required. | MySQL connection |
username | Required. | MySQL username |
password | Required. | MySQL password |
dbname | Required. | 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/* j a v a 2 s . com*/
$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);
?>
Next chapter...
What you will learn in the next chapter:
- Definition for PHP mysqli_character_set_name() Function
- Syntax for PHP mysqli_character_set_name() Function
- Parameter for PHP mysqli_character_set_name() Function
- Return for PHP mysqli_character_set_name() Function
- Example - returns the default character set for the database connection
Home » PHP Tutorial » PHP MySQLi Functions