title: Is query result null?
body: <p>This is for a data import script, I want to check if the Category Name with a Parent ID already exists; if it does then it does not need to be added to the database. My check however is not stopping duplicate entries.</p>
  
  <pre><code>$i = 1;
  $check = FALSE;
  echo'&lt;br&gt;';
  do{
     //Turn import order into Colewood order. 
     $tieroffset = $i - 1;
  
     $tier = $csvdata[$r][$fields["Tier" . $i]];
  
     $query = ("SELECT name FROM base_categories WHERE name = '".$tier."' AND id = '".$tieroffset."'");
     $result = mysql_query($query);
     $result_array = mysql_fetch_array($result);
  
     if (empty($result_array)) {
  
         if($tier != null){ 
         $queryInsert = "INSERT INTO base_categories (parent_id,name) 
                          VALUES ('" . $tieroffset . "', '" . mysql_real_escape_string($csvdata[$r][$fields["Tier" . $i]]) . "')";
         }
  
          mysql_query($queryInsert);
  
          print_r($queryInsert);
     }                
  
     $i++;
  }while ($i &lt;= 6 || $check != FALSE);
  echo'    &gt;&gt;&gt;END PRODUCT&lt;br&gt;';
  </code></pre>