mysqli_connect() function is used to connect php code
with MySQL database. It returns resource if connection is established otherwise
null.
Syntax:
resource mysqli_connect(server,username,password)
mysqli_close()
mysqli_close() function is used to close the
connection.
It is used to disconnect php code with MySQL database. It
returns true if connection is closed otherwise false.
Syntax:
bool mysqli_close( resource $resource_link)
Example:
<?php
$servername=
'localhost’;
$username = 'root';
$password =
'';
$con =
mysqli_connect($servername, $username, $password);
if(! $con )
{
die('Could not connect: ' .
mysqli_error());
}
echo 'Connected
successfully';
mysqli_close($con);
?>
Output:
Connected
successfully
No comments:
Post a Comment