php8.5
Home/ Manual/ mysql / functions/ mysql_close

mysql_close

PHP function Edit on GitHub ✎

(PHP 4, PHP 5)

Close MySQL connection

Note mysqli_closePDO: Assign the value of null to the PDO object

Description

mysql_close(resource $link_identifier = NULL): bool

mysql_close() closes the non-persistent connection to the MySQL server that's associated with the specified link identifier. If link_identifier isn't specified, the last opened link is used.

Sets

Parameters

Return Values

Success

Examples

mysql_close() example

php
<?php
$link = mysql_connect('localhost', 'mysql_user', 'mysql_password');
if (!$link) {
    die('Could not connect: ' . mysql_error());
}
echo 'Connected successfully';
mysql_close($link);
?>

The above example will output:

output
Connected successfully

Notes

Note

mysql_close() will not close persistent links created by mysql_pconnect(). For additional details, see the manual page on persistent connections.

See Also

Source: reference/mysql/functions/mysql-close.xml · from the official PHP manual (php/doc-en)