title: "Call to a member function fetch_assoc() on boolean"
body: <p>I've seen a bunch of questions about this error, but none of them seemed to have an answer that solved my problem... Sorry if I missed one.</p>
  
  <p>My script keeps giving me an error saying </p>
  
  <blockquote>
    <p>Call to a member function fetch_assoc() on boolean</p>
  </blockquote>
  
  <p>but I don't see how this is the case.</p>
  
  <p>Both <code>$mysqli_query</code> and <code>$mysqli_query-&gt;fetch_assoc()</code> are objects. Those respectively being:</p>
  
  <pre><code>object(mysqli_result)#4 (5) {
  ["current_field"]=&gt;
    int(0)
  ["field_count"]=&gt;
    int(2)
  ["lengths"]=&gt;
    NULL
  ["num_rows"]=&gt;
    int(1)
  ["type"]=&gt;
    int(0)
  }
  </code></pre>
  
  <p>and </p>
  
  <pre><code>array(2) {
  ["date"]=&gt;
    string(10) "2016-11-19"
  ["roles"]=&gt;
    string(241) "{"eu":{"host":{"max":2,"0":"U0SEMUG8L"},"chat":{"max":1,"0":"U0SEMUG8L"},"bg":{"max":2,"0":"U0SEMUG8L"}},"us":{"host":{"max":2,"0":"U0SEMUG8L","1":"U0SEMUG8L","2":"U0SEMUG8L"},"chat":{"max":1,"0":"U0SEMUG8L","1":"U0SEMUG8L"},"bg":{"max":2}}}"
  }
  </code></pre>
  
  <p>These also produce the same error:</p>
  
  <pre><code>SELECT * FROM `hosting_signups`
  SELECT * FROM `hosting_signups` WHERE 1
  </code></pre>
  
  <p>When the following is run in PhpMyAdmin, it works fine:</p>
  
  <pre><code>SELECT * FROM `hosting_signups` WHERE `date`='2016-11-19'
  </code></pre>
  
  <p>Does anyone know what I'm doing wrong? Here is the relevant code:</p>
  
  <pre><code>$mysqli_cmd = "SELECT * FROM `hosting_signups` WHERE `date`='" . $next_karaoke-&gt;format("Y-m-d") . "'";
  $mysqli_query = $mysqli-&gt;query($mysqli_cmd);
  //var_dump($mysqli_query-&gt;fetch_assoc()); // Oddly, when uncommented this terminates the 
                                            // whole while loop below, and the error is not 
                                            // produced but my code inside does not run. I'm 
                                            // not sure if this is at all related to my problem.
  
  while($row = $mysqli_query-&gt;fetch_assoc()) {}
  </code></pre>
  
  <p><strong>EDIT:</strong>
  I've modified my code a bit, with some more debugging, to be:</p>
  
  <pre><code>$mysqli_cmd = "SELECT * FROM `hosting_signups` WHERE `date`='" . $next_karaoke-&gt;format("Y-m-d") . "'";
  $mysqli_query = $mysqli-&gt;query($mysqli_cmd);
  
  var_dump($mysqli_cmd);
  var_dump($mysqli-&gt;error);
  
  while($row = $mysqli_query-&gt;fetch_assoc()) {}
  </code></pre>
  
  <p>The output is:</p>
  
  <pre><code>string(57) "SELECT * FROM `hosting_signups` WHERE `date`='2016-11-19'"
  string(0) ""
  Fatal error:  Call to a member function fetch_assoc() on boolean in 
  /home2/bugfroggy/public_html/hosting_signup.php on line 63
  </code></pre>
  
  <p><strong>EDIT 2:</strong>
  Was a stupid mistake on my end.. I was accidentally changing the value of <code>$mysqli_query</code> in the <code>while</code> loop instead of the query variable for <em>another</em> query I was doing inside of the loop. Problem solved!</p>