title: Problem with wrong parameter count in mysqli
body: <p>I created a function i intent to use in running my queries:</p>
  
  <pre><code>function selectquery ($sql, $params)
      {
         $connection = getConnect ();
         $result = $connection-&gt;prepare("$sql");
         $result-&gt;bind_param($params);
         $status = $result-&gt;execute();
         $return=array('obj'=&gt;$result, 'status' =&gt; $status, 'data'=&gt;array());
         $meta = $connection-&gt;result_metadata();  
         while ( $field = $meta-&gt;fetch_field() ) 
         {  
              $parameters[] = &amp;$row[$field-&gt;name];  
         }  
         call_user_func_array(array($result, 'bind_result'), $parameters);  
  
         while ( $stmt-&gt;fetch()) 
         {  
            $x = array();  
            foreach( $row as $key =&gt; $val ) 
            {  
               $x[$key] = $val;  
            }  
            $return['data'][] = $x;  
         } 
         $result-&gt;close(); 
         return $return; 
      }
  </code></pre>
  
  <p>And this is how i run my query:</p>
  
  <pre><code>$resultobj=selectquery ("select id from employers where subdomain = ? ", "s, $reg_subdomain");
  </code></pre>
  
  <p>It comes up with this error: </p>
  
  <p>Warning: Wrong parameter count for mysqli_stmt::bind_param() in /home/kju/public_html/ejjk.com/functions.php on line 42</p>
  
  <p>Fatal error: Call to undefined method mysqli::result_metadata() in /home/kju/public_html/ejjk.com/functions.php on line 45</p>
  
  <p>What is the possible problem and how can i get it fixed</p>
  
  <p>Thanks</p>