title: When should I connect to my database from php scripts?
body: <p>I have pages on my site that use the database and pages that don't.</p>
  
  <p>When ever I need the database, I connect using <code>$conn = connect()</code>. But this means I need to put it in everywhere its needed. If I put it in an include file and put that file into every page it would connect even when the database is not needed. Would this be a good idea? Would creating a connection cause problems or other issues when not needed, or should I connect only when needed?</p>