title: php mysqli check if mysqli query returns false
body: <p>How can I check mysqli query if it returns boolean(false) or the result?
  If I try getting the num_rows I get php error because I'm trying to access a non object as object. But I need to check this because if its false I have to set a variable and if its not than get the result of the query.</p>
  
  <p>my query looks like this:</p>
  
  <pre><code>&lt;?php
  $q = "SELECT `id` FROM `table` ORDER BY `id` DESC LIMIT 0, 1";
  $res = mysqli-&gt;query($q);
  ?&gt;
  </code></pre>