Jump to content

Is its important that we have to close MYSQL Connection


binumathew

Recommended Posts

Is its important that we have to close MYSQL Connection in php after i use  a connection

i am using following functions

 

function GetConnection()
	{
		$COLAS_con=mysql_connect("localhost","root","pass");
		mysql_select_db("DB_COLAS",$COLAS_con);
		return $COLAS_con;
	}
function Connection_Close($COLAS_con)
	{
		mysql_close($COLAS_con);
	}		

 

i use this in my one of code

 

<?php
$UName='1'; 
echo $now = date("Y/m/d", strtotime('+5 hour+30 minutes') );
include "DB_Connection.php";
$ColasObj=new DBConnection;
$ColasCon=$ColasObj->GetConnection();
$ed=$ColasObj->NoStud($ColasCon,$UName);
$ef=$ColasObj->NoPreStud($ColasCon,$now);
$absent=$ed-$ef;
?>	

 

can i use close connection??is it important if so where??

 

Link to comment
Share on other sites

Because of php's garbage collection there is generally need need to worry about closing connections or cleaning up resources.

 

Did you type 2 "needs" by accident or was the 1st meant to be no? You have 2 needs there. Keep in mind if need or no, both can have the effect to drastically alter  the meaning of your sentence. I think you should clarify.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.