# 1 MySql connection vs. er, more then 1

**URL:** <https://forum.kirupa.com/t/1-mysql-connection-vs-er-more-then-1/291953>\
**Category:** programming\
**Created:** [July 8, 2009, 8:34am UTC](https://forum.kirupa.com/t/1-mysql-connection-vs-er-more-then-1/291953 "2009-07-08T08:34:56Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![MikeDS](https://avatars.discourse-cdn.com/v4/letter/m/a587f6/32.png) [@MikeDS](https://forum.kirupa.com/u/MikeDS)\
**Post date:** [July 8, 2009, 8:34am UTC](https://forum.kirupa.com/t/1-mysql-connection-vs-er-more-then-1/291953/1 "2009-07-08T08:34:56Z")

</div>

Hi guys

Very quick question, I’m just wondering which is more resourceful for connecting to a MySql db from PHP - having just one connection that persists throughout the site, or creating a connection everytime a query is run…

For example, say that I create a function that runs mysql\_connect() and mysql\_select\_db(), and call this function everytime I run a query, is this just a horrible use of resources, and is it more beneficial to just run these once within a function file that gets included in each page?

Thanks guys, hopefully I’ve made myself clear, and I probably know the answer already, just want to make sure!!!
