title: PHP & MySQL: mysqli_num_rows() expects parameter 1 to be mysqli_result, boolean given
body: <p>I'm trying to Integrate HTML Purifier <a href="http://htmlpurifier.org/" rel="noreferrer">http://htmlpurifier.org/</a> to filter my user submitted data but I get the following error below. And I was wondering how can I fix this problem?</p>
  
  <p>I get the following error.</p>
  
  <pre><code>on line 22: mysqli_num_rows() expects parameter 1 to be mysqli_result, boolean given 
  </code></pre>
  
  <p>line 22 is. </p>
  
  <pre><code>if (mysqli_num_rows($dbc) == 0) {
  </code></pre>
  
  <p>Here is the php code.</p>
  
  <pre><code>if (isset($_POST['submitted'])) { // Handle the form.
  
      require_once '../../htmlpurifier/library/HTMLPurifier.auto.php';
  
      $config = HTMLPurifier_Config::createDefault();
      $config-&gt;set('Core.Encoding', 'UTF-8'); // replace with your encoding
      $config-&gt;set('HTML.Doctype', 'XHTML 1.0 Strict'); // replace with your doctype
      $purifier = new HTMLPurifier($config);
  
  
      $mysqli = mysqli_connect("localhost", "root", "", "sitename");
      $dbc = mysqli_query($mysqli,"SELECT users.*, profile.*
                                   FROM users 
                                   INNER JOIN contact_info ON contact_info.user_id = users.user_id 
                                   WHERE users.user_id=3");
  
      $about_me = mysqli_real_escape_string($mysqli, $purifier-&gt;purify($_POST['about_me']));
      $interests = mysqli_real_escape_string($mysqli, $purifier-&gt;purify($_POST['interests']));
  
  
  
  if (mysqli_num_rows($dbc) == 0) {
          $mysqli = mysqli_connect("localhost", "root", "", "sitename");
          $dbc = mysqli_query($mysqli,"INSERT INTO profile (user_id, about_me, interests) 
                                       VALUES ('$user_id', '$about_me', '$interests')");
  }
  
  
  
  if ($dbc == TRUE) {
          $dbc = mysqli_query($mysqli,"UPDATE profile 
                                       SET about_me = '$about_me', interests = '$interests' 
                                       WHERE user_id = '$user_id'");
  
          echo '&lt;p class="changes-saved"&gt;Your changes have been saved!&lt;/p&gt;';
  }
  
  
  if (!$dbc) {
          // There was an error...do something about it here...
          print mysqli_error($mysqli);
          return;
  }
  
  }
  </code></pre>