title: Database Error: [mysqli.mysqli]: User already has more than 'max_user_connections' active connections
body: <p>I have a site that gets just about 100 people everyday but I got this error message when log in as a user:</p>
  
  <pre><code>Warning: mysqli::mysqli() [mysqli.mysqli]: (42000/1203): User mexautos_Juan already has more than 'max_user_connections' active connections in /home/mexautos/public_html/kiubbo/data/model.php on line 26
  
  Warning: mysqli::query() [mysqli.query]: Couldn't fetch mysqli in /home/mexautos/public_html/kiubbo/data/model.php on line 87
  Query failed 
  </code></pre>
  
  <p>I refresh the page a couple of time and now its ok, but since I dont have that many users I suspect the error its in my code, where should I look for it?</p>
  
  <p>Thx</p>
  
  <p>Edit: this is the model file:</p>
  
  <pre><code>&lt;?php
  /* 
  
      Model is the base class from which the other
      model classes will be derived. It offers basic
      functionality to access databases
  
  */ 
  require_once($_SERVER['DOCUMENT_ROOT'].'/config.php'); 
  require_once(SITE_ROOT.'includes/exceptions.php'); 
  
  class Model {
  
      private $created;
      private $modified;
  
      static function getConnection()
      {
          /* 
  
              Connect to the database and return a
              connection or null on failure
  
          */
  
          $db = new mysqli (DB_HOST, DB_USER, DB_PASS, DB_NAME);
          if(!$db) {
              echo mysql_error();
              throw new Exception('Could not connect to database', EX_NO_DATABASE_CONNECTION);
          }
  
          return $db;
  
      }
  
      static function execSQL($query)
      {
      /*
              Execute a SQL query on the database
              passing the tablename and the sql query.
              Returns the resultset
      */
  
  
          $db = null;
          $results = null;
          //echo "query is $query";
  
          try
          {
              $db = Model::getConnection();
              $results = $db-&gt;query($query);
              if(!$results) {
                  throw new Exception('Query failed', EX_QUERY_FAILED );
              }
          }
          catch(Exception $e)
          {
              /*  errors are handled higher in the
                      object hierarchy
              */
  
              throw $e;
          }
  
          Model::closeConnection($db);
  
          return $results;
      }
  
      static function execSQl2($query)
      {
      /*
              Execute a SQL query on the database
              passing the tablename and the sql query.
              Returns the LAST_INSERT_ID
      */
  
  
          $db = null;
          $lastid = null;
          //echo "query is $query";
  
          try
          {
              $db = Model::getConnection();
              $results = $db-&gt;query($query);
              if(!$results) {
                  throw new Exception('Query failed', EX_QUERY_FAILED );
              }
              $lastid = $db-&gt;insert_id;
          }
          catch(Exception $e)
          {
              /*  errors are handled higher in the
                      object hierarchy
              */
  
              throw $e;
          }
  
          Model::closeConnection($db);
  
          return $lastid;
      }
  
      function delete($table, $id, $conditions = '')
      {
          $query = "delete from $table where id = $id";
          try
          {
              $db = Model::getConnection();
              $results = Model::execSQL($query);
              if(!$results){
                  throw new Exception('Could not delete this object', EX_DELETE_ERROR);
              }
              return $results-&gt;num_rows;
          }
  
          catch(Exception $e)
          {
              throw $e;
          }
      }
  
      static function closeConnection($db)
      {
          $db-&gt;close();
      }
  
      function getCreated()
      {
          return $this-&gt;created;
      }
  
      function setCreated($value)
      {
          $this-&gt;created = $value;
      }
  
      function getModified()
      {
          return $this-&gt;modified;
      }
  
      function setModified($value)
      {
          $this-&gt;modified = $value;
      }
  
  
  
  }
  
  ?&gt;
  </code></pre>