PHP MySQL Database Connection Close Example

PHP MySQL Database Connection Close Example


Posted in : PHP Posted on : February 3, 2011 at 4:53 PM Comments : [ 0 ]

if you need to close database connection then php provide mysql_close() function that accept connection as parameter and return boolean value.

PHP MySQL Database Connection Close Example:

After creating database connection in php application, if you need to close database connection then php provide mysql_close() function that accept connection as parameter and return boolean value(true for success or false for failure).

Syntax:

mysql_close(connection)

Example:

<?php
$connection = mysql_connect("localhost","root","root");
if (!$connection) {
die('PHP Mysql database connection could not connect : ' . mysql_error());
}
else{
echo "PHP MySql database connection created.<br />";
}
mysql_close($connection); 
echo "PHP MySql database connection closed.<br />";
?>

After running this example the output is:

Output:

PHP MySql database connection created.
PHP MySql database connection closed.

Download Example Code

Go to Topic «PreviousHomeNext»

Your Comment:


Your Name (*) :
Your Email :
Subject (*):
Your Comment (*):
  Reload Image
 
 

 
Tutorial Topics