PHP Tutorial





Español Français 中文 Deutsch Portuguese Japanese nederlands
   
 
PHP Topics
Introduction Introduction
Syntax Syntax
Data Types Data Types
Operators Operators
Control Structures Control Structures
Functions Functions
Pre-defined Function Pre-defined Function
Calendar Functions Calendar Functions
Date and Time Date and Time
Array Functions Array Functions
Array List Array Functions List1
Array Function List Array Functions List2
Math Functions Math Functions
PHP MYSQL Functions PHP Mysql Functions
File Handling File Handling
Error Handling Error Handling
DB Size DB Size
PHP Mail PHP Mail
String Tokens String Tokens
String Functions String Functions
String Functions List String Functions List1
String Functions List2 String Functions List2
Session Functions Session Functions
Cookies Functions Cookies Functions
Form Variables Form Variables
Running PHP from JS Running PHP from JS
Array To JS Array To JS
JS Array Array to PHP
Encryption Encryption
Common Header Common Header
Forums Ask Your Doubts
Scraps More about PHP
Feedback Feedback
 




mysql_close() Function in PHP


Tutorials »Php »

Topic

What is mysql_close function in PHP?
How does mysql_close() works?




Explanation

The mysql_close function is used to close MySQL connection.

Syntax
bool mysql_close ( [resource link_identifier])

Returns: TRUE on success, FALSE on error.

Once you have opened a connection to your MySQL database from your PHP document, you can close it again using the mysql_close() function with link identifier as argument. If link_identifier is not specified,then the last opened link is used.

Using mysql_close() is not usually necessary, as non-persistent open links are automatically closed at the end of the script's execution

mysql_close() will not close persistent links created by mysql_pconnect().

Example


<?php

// Attempt to connect to the default database server
$link = mysql_connect("mysql_host", "mysql_user", "mysql_password")
or die ("Could not connect");

print 'You are connected';

//close connection
mysql_close($link) ;
?>


See also: mysql_connect() and mysql_pconnect()





Other Links

web hosting