I have a webpage with some mysql querys,
I must start new db connection and db close after every query or its more efficiently start an only one db connection at the top of the code and close at the bottom of the script?
Thanks!
I have a webpage with some mysql querys, I must start new db connection
Share
Never create a new connection for every query; it’s very wasteful and will overburden your MySQL server.
Creating one connection at the top of your script is enough – all subsequent queries will use that connection until the end of the page. You can even use that connection in other scripts that are
include()ed into the script with yourmysql_connect()call in it.