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??

 

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.

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.