astralaaron Posted March 30, 2008 Share Posted March 30, 2008 I have been viewing a lot of other peoples php codes on this site for months.. I do not see the mysql_close() being used? when is a situation where you would close mysql? doesnt mysql close when the page is left? Link to comment Share on other sites More sharing options...
daredevil14 Posted March 30, 2008 Share Posted March 30, 2008 I have been viewing a lot of other peoples php codes on this site for months.. I do not see the mysql_close() being used? when is a situation where you would close mysql? doesnt mysql close when the page is left?mysql_close() php function is used to close the database server connection, it is like when you assign something to a variable and then empty this variable so that you free the memory resources ( because any variable you open, takes a place in the memory )... I suggest that you close everything you start, it is like a better programming practice... Link to comment Share on other sites More sharing options...
astralaaron Posted March 30, 2008 Author Share Posted March 30, 2008 mysql_close() php function is used to close the database server connection, it is like when you assign something to a variable and then empty this variable so that you free the memory resources ( because any variable you open, takes a place in the memory )... I suggest that you close everything you start, it is like a better programming practice...I understand.. how do you close a variable? Link to comment Share on other sites More sharing options...
astralaaron Posted March 30, 2008 Author Share Posted March 30, 2008 mysql_close() php function is used to close the database server connection, it is like when you assign something to a variable and then empty this variable so that you free the memory resources ( because any variable you open, takes a place in the memory )... I suggest that you close everything you start, it is like a better programming practice...I understand.. how do you close a variable? Link to comment Share on other sites More sharing options...
daredevil14 Posted March 30, 2008 Share Posted March 30, 2008 I understand.. how do you close a variable?I don't know how to close a normal variable in php... but - for example - in ASP it is done by setting your variable_name equal to nothing ex :<%Dim name''the use of the variable...'set name = nothing%> Link to comment Share on other sites More sharing options...
Lulzim Posted March 30, 2008 Share Posted March 30, 2008 PHP performs a garbage collection at the end of execution on every script - destroys all the objects and variables not being used, so there is no need to destroy/close the variables manually.The same thing goes with mysql connections Using mysql_close() isn't usually necessary, as non-persistent open links are automatically closed at the end of the script's execution. http://www.php.net/mysql_closeIf you really want to destroy variables manually use unset() Link to comment Share on other sites More sharing options...
Synook Posted March 31, 2008 Share Posted March 31, 2008 mysql_close() is only really useful when you connect to multiple database servers. Link to comment Share on other sites More sharing options...
sangeetha Posted April 8, 2008 Share Posted April 8, 2008 Thanks.. A very useful link.. I too had this doubt.. But got it cleared now.. Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.