Jump to content
xisto Community
Sign in to follow this  
kilz

How does mysql_free_result() work ? how this function works??

Recommended Posts

when I use mysql_free_result() to free the memory. . .seem nothing happened.how if I don't use this function.one more question is. ..mysql_close(). . why should I close mysql connection??

Share this post


Link to post
Share on other sites

If you don't free your result it will simply stay in the memory until the script execution is over. Basically only thing (other than memory usage) where it matters is that if you happen to have several queries, you can be sure that there are no "ghost" results around. So you will be always processing data from right results. It is good programming style to free your results when you donät need them anymore.I do not know when unclosed database connections get closed automatically (probably depends on PHP configuration), but if it doesn't do it when the script execution ends it might be a security risk. Ie. the connection could be hijacked. Again it is good programmign style to close your database connections when you don't need them. Also if you are doing queries from different databases, closing the connections ensures that you are not doing them from wrong database (ie. using wrong open handle)

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

×
×
  • Create New...

Important Information

Terms of Use | Privacy Policy | Guidelines | 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.