binumathew Posted October 16, 2009 Share Posted October 16, 2009 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 https://forums.phpfreaks.com/topic/177892-is-its-important-that-we-have-to-close-mysql-connection/ Share on other sites More sharing options...
trq Posted October 16, 2009 Share Posted October 16, 2009 Because of php's garbage collection there is generally need need to worry about closing connections or cleaning up resources. Link to comment https://forums.phpfreaks.com/topic/177892-is-its-important-that-we-have-to-close-mysql-connection/#findComment-937952 Share on other sites More sharing options...
waynew Posted October 17, 2009 Share Posted October 17, 2009 As thorpe said, the connection is closed as soon as your script stops executing. Link to comment https://forums.phpfreaks.com/topic/177892-is-its-important-that-we-have-to-close-mysql-connection/#findComment-938789 Share on other sites More sharing options...
Daniel0 Posted October 17, 2009 Share Posted October 17, 2009 For the most part, the only reason why you would want to manually clean up resources in PHP is if your script is going to run for a long time. Link to comment https://forums.phpfreaks.com/topic/177892-is-its-important-that-we-have-to-close-mysql-connection/#findComment-938821 Share on other sites More sharing options...
keldorn Posted October 24, 2009 Share Posted October 24, 2009 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 https://forums.phpfreaks.com/topic/177892-is-its-important-that-we-have-to-close-mysql-connection/#findComment-943518 Share on other sites More sharing options...
448191 Posted October 24, 2009 Share Posted October 24, 2009 What do YOU think? Link to comment https://forums.phpfreaks.com/topic/177892-is-its-important-that-we-have-to-close-mysql-connection/#findComment-943522 Share on other sites More sharing options...
keldorn Posted October 24, 2009 Share Posted October 24, 2009 What do YOU think? Parse error: syntax error, unexpected 'need' in Re: Is its important that we have to close MYSQL Connection on post 2, assuming 'no' xD Link to comment https://forums.phpfreaks.com/topic/177892-is-its-important-that-we-have-to-close-mysql-connection/#findComment-943541 Share on other sites More sharing options...
Mchl Posted October 24, 2009 Share Posted October 24, 2009 Boy, you should be doing this full time. Link to comment https://forums.phpfreaks.com/topic/177892-is-its-important-that-we-have-to-close-mysql-connection/#findComment-943542 Share on other sites More sharing options...
448191 Posted October 24, 2009 Share Posted October 24, 2009 Parse error: syntax error, unexpected 'need' in Re: Is its important that we have to close MYSQL Connection on post 2, assuming 'no' Bots are banned. Link to comment https://forums.phpfreaks.com/topic/177892-is-its-important-that-we-have-to-close-mysql-connection/#findComment-943558 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.