title: Workaround for error 1203 max_user_connections exceeded
body: <p>I'm trying to transfer some data from an old website to a new one.
  I've moved the old database to the new website and wrote this piece of code to programmatically insert wordpress pages based on data from the old database. Only problem is, when I run it, it quickly causes my website to break as I exceed the max number of user connections.</p>
  
  <p>I can't seem to up the max_user_connections variable from phpMyAdmin, so I'm looking to find a way to keep my code limited to one connection while it creates the pages.</p>
  
  <pre><code>$dbname = 'mydb';
  $dbhost = 'myhost';
  $dbuser = 'myuser';
  $dbpass = 'mypass';
  $conn = mysqli_connect($dbhost, $dbuser, $dbpass, $dbname);
  
  if (!$conn){
      die("could not connect " . mysqli_connect_errno() . mysqli_connect_error());
  }
  
  $qry = "SELECT name, date, artist, owner, style FROM paintings";
  $result = mysqli_query($conn, $qry);
  
  $posts_array = array();
  
  if ($result-&gt;num_rows &gt; 0){
      while($row = mysqli_fetch_array($result)){
          global $user_ID;
  
          $new_post = array(
                          'post_title' =&gt; $row['name'],
                          'post_content' =&gt; 'Artist: '.$row['artist'].'&amp;nbsp Style: '.$row['style'].'&amp;nbsp Date: '.$row['date'].'&amp;nbsp &amp;nbsp Images: &amp;nbsp &amp;nbsp Documents:',
                          'post_author' =&gt; $user_ID,
                          'post_type' =&gt; 'pages',
                          );
  
          $posts_array[]=$new_post;
      }
  } else {
      echo "no resulting rows";
  }
  
  mysqli_close($conn);
  
  foreach ( $posts_array as $post) {
      $post_id = wp_insert_post($post);
  }
  </code></pre>