title: "Call to a member function fetch_row() on a non-object" in spite of error handling
body: <p>I want to execute a query but php/mysql throws </p>
  
  <blockquote>
    <p>Call to a member function fetch_row() on a non-object</p>
  </blockquote>
  
  <p>even though </p>
  
  <pre><code>if(!$results) 
  </code></pre>
  
  <p>should filter out empty results. The error message points to </p>
  
  <pre><code>$row = $results-&gt;fetch_row();
  </code></pre>
  
  <p>This is the whole code:</p>
  
  <pre><code>&lt;?php
  $query = 'DELETE FROM `products` WHERE `company` ='.$id_nummer;
  
  $results = $link-&gt;query($query);
  if(!$results)
  {
    echo $link-&gt;error;
  }
  else
  {
    $row = $results-&gt;fetch_row();
    $wanted_result = $row[0];
  }
  ?&gt;
  </code></pre>
  
  <p>Where is the cause for this?</p>
  
  <p>EDIT: I solved it by replacing</p>
  
  <pre><code>if(!$results)
  </code></pre>
  
  <p>with</p>
  
  <pre><code>if(!is_object($results))
  </code></pre>
  
  <p>and it works.</p>