title: Mysqli num rows not working
body: <p>I have a fairly basic script (i'm used to mysql but i'm moving to mysqli) </p>
  
  <pre><code>&lt;?php
  include("../includes/functions.php");
  /////////////////////////////////////////////////////////////////////////
  $debugMode = 1;
  /////////////////////////////////////////////////////////////////////////
  if (isset($_GET['u']))
  {
      // database connection
      $c = mysqli_connect("localhost", "xxx", "xxx", "xxx");
  
      // initial query to check if the domain is already in the database
      $q = $c-&gt;query("SELECT * FROM `domains` WHERE `domain_name`='".trim($s[0])."'");
      $v = $q-&gt;fetch_assoc();
      $r = $q-&gt;num_rows;
  
      // check if the string exists in the database
      if ($r &gt; 0)
      {
          // do not enter if greater than 0
      } else {        
          // vars
          $u = $_GET['u'];
  
          // DEBUG
          if ($debugMode)
          {
            $fp = fopen('u.txt', 'a');
            fwrite($fp, "$u" . "\n");
            fclose($fp);      
          }
  
          // do a split of "|"
          $s = explode("|", $u);
  
          // check alexa rank and update
          $alexa = alexa_rank($s[0]);
  
          // check connection
          if (mysqli_connect_errno())
          {
           echo mysqli_connect_error();
          } else {        
           // insert query if there is no errors
           $i = $c-&gt;query("INSERT INTO `domains` (`domain_id`,`domain_name`,`domain_pr`,`domain_alexa_rank`,`domain_moz_da`,`domain_moz_pa`,`domain_date`) VALUES ('','".$s[0]."','".$s[1]."','".$alexa."','".$s[2]."','".$s[3]."',NOW())"); 
          }   
      }   
  } else {    
      header("Location: http://www.site.info/");
  }
  ?&gt;
  </code></pre>
  
  <p>It looks fairly simple, the problem is the count part isn't working, it's still adding to the database duplicate entries, i also tried:</p>
  
  <pre><code>mysqli_num_rows($q);
  </code></pre>
  
  <p>This still doesn't seem to work, am i missing something simple?</p>
  
  <p>thanks guys</p>