title: How to reuse a MySQLi connection
body: <p>I've ran into an issue with <em><strong>user already has more than 'max_user_connections' active connections</strong></em></p>
  <p>This happens because I use functions for the website functionality, each function contains a</p>
  <pre><code>$mysqli = connect();
  </code></pre>
  <p>Though at the same time, each function closes the mysqli at the end of function</p>
  <pre><code>mysqli_close($mysqli);
  </code></pre>
  <p>I <strong>do not</strong> want to include <code>$mysqli</code> as a parameter of the function, as the function is dynamic and would be tiresome to include it with each function call.</p>
  <p>the <code>connect()</code> function just contains:</p>
  <pre><code>$mysqli = new mysqli(...);
  return $mysqli;
  </code></pre>
  <p>I believe the error is thrown because the function sometimes calls itself for different executions, based on user input and pre-requisites... <em>even though the mysqli is closed at the end of the function</em>...</p>
  <p>I'd like to know if there is a way of re-using a $mysqli connection sort of like in a global way...</p>
  <p>I'm not sure whether I've explained myself fully so if you need some more information please leave a comment.</p>