Php – thesql_free_result() or thesql_close()

MySQLPHP

on my site database gets disconnected after few minutes and gets connected after few minutes automaticaly…..i think it is due to exceeding the mysql connections…what should i use mysql_free_result() or mysql_close()…..or let me know if there is any other problem….

Best Answer

This two functions do two completely different things.

MySql_Close() will close the connection to the database server, but that is done automatically at the end of your script. So unless you only need the DB at the beginning to pull some data out and you are then processing the data for a long time, there is no need to close the connection manually.

MySql_Free_Result() on the other hand, well, frees the resource that holds rows returned by MySql_Query() meaning it frees up your memory and you can't use that resource any more to retrieve data. If your DB server is located on another machine, then this does not have any effect on the DB server.

As far as your problem go: look at your configuration to see how many connections your DB server accepts. Also examine your log files to determine what exactly causes your server to crash and then work from there.