How to Close mySQL Connections in a Right Way

by Hiroshi on June 19, 2008

in MySQL

After execution of mysql query its appropriate (even essential) to close mySQL connection. Use the following script to close mySQL connection.

MySQL Query For Adding Some Record In DataBase

$sInsertQuery = "INSERT INTO tb VALUES('', '$sName', '$sPassword', '$sEmail')";
	if (mysql_query($sInsertQuery))
	{
		print "Record Added";
	}

Closing MySQL Connection

mysql_close();

Mixing Things Together

$sInsertQuery = "INSERT INTO tb VALUES('', '$sName', '$sPassword', '$sEmail')";
	if (mysql_query($sInsertQuery))
	{
		print "Record Added";
		mysql_close();
	}

Related Posts

Previous post:

Next post: