title: Do I need a php mysql connection in each function that uses database?
body: <p>I am creating a php restful API and currently I have the database connection information in each function.</p>
  
  <pre><code>//Connect To Database
      $hostname=host;
      $username=username;
      $password=password;
      $dbname=dbname;
  
      mysql_connect($hostname, $username, $password) OR DIE('Unable to connect to database! Please try again later.');
      mysql_select_db($dbname);
  mysql_query($sqlApiAccess) or die('Error, insert query failed');
  </code></pre>
  
  <p>What is the best way of doing this, Can I have one database connection per php file?  Or do I need to do it per function that uses the database.</p>