title: Unable to get results php mysqli select with bind
body: <p>I am attempting to return a result set from mysql in php using mysqli. I have attempted several different ways, but they either end in errors, or empty arrays being returned. I know the query is good because I can run it in my db admin client replacing the question mark with the string needed and it returns as expected. Does anyone see something I have missed? Looks like it should be working to me, but obviously something has to be wrong. ¯_(ツ)_/¯</p>
  
  <pre><code>&lt;?php
  
  class db extends mysqli{
  
      function __construct(){
  
          parent::__construct(PUBP_HOST, PUBP_USER, PUBP_PASS, PUBP_DB);
  
      }
  
  
     /* 
     --------------------------------------------------------------------------*/
     function read_agency_phones($agency_in){
  
          $returnArray = array();
  
          if($stmt = $this-&gt;prepare("SELECT firstname, lastname, agency, phonenumber FROM employees WHERE agency = ?")){
  
              try{
  
                  $stmt-&gt;bind_param('s', $agency_in);
                  $stmt-&gt;execute();
                  $stmt-&gt;bind_result($first, $last, $agency, $phone);
  
  
  
                  while($stmt-&gt;fetch()){
  
                      $returnArray[] = array(
                          'first_name'    =&gt; $first,
                          'last_name'     =&gt; $last,
                          'agency'        =&gt; $agency,
                          'phonenumber'   =&gt; $phone
                      );
  
                  }
  
                  $stmt-&gt;free_result();
                  $stmt-&gt;close();
  
                  return $returnArray;
  
              } catch (Exception $ex) {
  
                  return $ex-&gt;getMessage();
  
              }
  
          }
  
          return 'failed001';
  
  
     }
  
  }
  
  
  $db = new db();
  
  $results = $db-&gt;read_agency_phones("SOME_STRING");
  
  
  
  echo '&lt;pre&gt;';
  echo var_export($results, true);
  echo '&lt;/pre&gt;';
  die;
  </code></pre>
  
  <p>The <code>agency</code> field in the database is of type VARCHAR(10).</p>
  
  <p>When running the following query in admin panel, results are returned as expected:</p>
  
  <pre><code>SELECT firstname, lastname, agency, phonenumber FROM employees WHERE agency = "THE-AGENCY"
  </code></pre>