mysql_close

mysql_close — Close MySQL connection

Version: (PHP4, PHP5)

Syntax: bool mysql_close  ([ resource $link_identifier  ] )

Description: The mysql_close() function closes a non-persistent MySQL connection. $link_identifier Optional. Specifies the MySQL connection to close. If not specified, the last connection opened by mysql_connect() is used.

Return Values: Returns TRUE on success or FALSE on failure.
Example mysql_close():

<?php
$con = mysql_connect("localhost","user","password");
if (!$con)
  {
  die('Could not connect: ' . mysql_error());
  }

echo 'Connected successfully';

mysql_close($con); ?>

The above example will output: Connected successfully
<?
    function mysql_close($link = NULL)
      {
        $link = mysql_resolve_link($link);
        return mysqli_close($link);
      }
?>
Notes:Using mysql_close() isn't required, as non-persistent connections are automatically closed at the end of the script.

Post Comment
Login to post comments