Name
mysql_close
Synopsis
boolean mysql_close([cresource connection
])
Closes the
most recently opened MySQL DBMS connection. The function takes an
optional connection
resource handle as a
parameter. If no parameter is passed, the most-recently opened
connection that is still open is assumed.
The function returns true
on success and
false
on failure.
This function is rarely used, as nonpersistent connections opened
with mysql_connect( )
are closed when a script
ends. Connections opened with mysql_pconnect( )
cannot be closed. Therefore, the only practical use of this function
is to close a nonpersistent connection in a script where resource use
must be minimized.
Example
<?php $query = "SELECT * FROM presents"; $connection = mysql_connect("localhost", "fred", "shhh"); mysql_select_db("wedding", $connection); $result = mysql_query($query, $connection); while ($row = mysql_fetch_array($result)) echo $row["present"] . "\n"; mysql_close($connection); ?>
Get Managing & Using MySQL, 2nd Edition now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.