title: fetch_assoc mysqli returning empty
body: <p>I an trying to query a mySQL database using a PHP function. Intermittantly, the function that I am using does not seem to return a result. As far as I can detect, it's not a null response, and based on the function, it doesn't seem to be returning an invalid result ( the return string <em>Nuthin</em> in this case ).</p>
  
  <pre><code>function GeneratePiece2 ($sqlstr){
    $conn = new mysqli(gHOST, gUSER, gPASSWORD, gDATABASE);
    // Check connection
    if ($conn-&gt;connect_error) {
      die("Connection failed: " . $conn-&gt;connect_error);
    }
    $result = $conn-&gt;query($sqlstr);
    $returnable = "";
    if ($result-&gt;num_rows &gt; 0) {
      while ($row = $result-&gt;fetch_assoc()) {
          echo $row;
          $returnable = $row;
      }
    } else {
      return "nuthin";
    }
    $conn-&gt;close();
    return $returnable;
  }
  </code></pre>
  
  <p>I've been using the same SQL Query of </p>
  
  <pre><code>SELECT  Name FROM Char_Name_full WHERE Male=1 AND DivisionID=12  ORDER BY RAND() LIMIT 1
  </code></pre>
  
  <p>Around 80% of the time I will receive a result of something like <strong>{"Name":"Christoph"}</strong> but 1 out of 10 returns nothing. </p>