title: How to store results of multiple queries in different array variables
body: <p>I need to get data from 2 different queries. I want to store them as 2 separate variables.</p>
  
  <p>First I tried this:</p>
  
  <pre><code>// 1. Create a database connection
  $mysqli = new mysqli(DB_SERVER, DB_USER, DB_PASS, DB_NAME, DB_PORT);
  
  if ($mysqli-&gt;connect_errno) {
      echo "No connection" ;
  }
  // 2. first query 
  $query = "CALL sp1('2015-01-01', '2015-01-31');";
  $result = $mysqli-&gt;query($query);
  
  $var1 = array();
  while($shop = $result-&gt;fetch_object()) {
      $var1[] = $shop;
  }
  
  echo '&lt;pre&gt;', print_r($var1), '&lt;/pre&gt;';
  $result-&gt;free();
  
  // 3. second query 
  $query = "CALL sp2('2015-01-01', '2015-01-31');";
  $result = $mysqli-&gt;query($query);
  
  $var2 = array();
  while($shop = $result-&gt;fetch_object()) {
      $var2[] = $shop;
  }
  
  echo '&lt;pre&gt;', print_r($var2), '&lt;/pre&gt;';
  </code></pre>
  
  <p>I get the data from 1st query however when php tries to fetch 2nd query I got this error:</p>
  
  <blockquote>
    <p>Fatal error: Call to a member function fetch_object() on boolean</p>
  </blockquote>
  
  <p>I read about multi_query but couldn't find anything about saving output from queries as separate variables.</p>
  
  <p>Additional info: Even when I switch queries always the second one is not correct. I don't know how to load second query and what is happening to the previous one (gets deleted when I write:result->free?)</p>