After reviewing someone's code, I noticed that they connect to their MySQL database in the header file (which is called by all of the *.php files). The way that I have been programming sites is to connect to the database only when I need to do a query or insert/update the tables and then immediately close the connection with "mysql_free_result ($result);" followed by "mysql_close();", sometimes I connect and close this connection a few times per script.
My question is "Is it OK to have a connection to the MySQL database open while a page loads?" (ie. connect to the db in my header script and then disconnect/close the connection in my footer script) like you have or am I doing it the preferred way? I am concerned with speed and also while my page is rendering, would my connection to the db stop others from connecting at the same time leaving them to wait until my footer file is called before they can connect.
Thanks for your help!