Close MySQL Connection in PHP

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
fazalbakhtiar
Forum Newbie
Posts: 1
Joined: Mon Oct 10, 2011 10:34 am

Close MySQL Connection in PHP

Post by fazalbakhtiar »

Basically i have desktop application which brings records or data from MySQL Database through PHP. i create a config file in PHP and creates a connection to the database there. after that i execute the query on some other PHP page which include the config page. i want to close the database connection after that. i am confused as there may be more than one user with open connection and may be his connection closes or the connection for that user will close?
User avatar
social_experiment
DevNet Master
Posts: 2793
Joined: Sun Feb 15, 2009 11:08 am
Location: .za

Re: Close MySQL Connection in PHP

Post by social_experiment »

If you are using mysql_connect() to create the connection it will reuse a existing connection. You can close the connection with mysql_close() but if the user closes the page the connection is probably also closed automatically.
“Don’t worry if it doesn’t work right. If everything did, you’d be out of a job.” - Mosher’s Law of Software Engineering
Post Reply