title: PHP Variables in MYSQL Select using PDO
body: <blockquote>
    <p><strong>Possible Duplicate:</strong><br>
    <a href="https://stackoverflow.com/questions/854128/find-duplicate-records-in-mysql">Find duplicate records in MySQL</a>  </p>
  </blockquote>
  
  
  
  <p>I am a newbe trying to find duplicates in a database with this function:</p>
  
  <pre><code>function uni($field, $value) {
          $sql= "SELECT * FROM user WHERE ".$field." = '".$value."'";
          $result = $pdo-&gt;query($sql);
          $rows = $result-&gt;fetchAll(PDO::FETCH_COLUMN, 1);
          return count($rows);
      }
  
  $username = $_POST['username']; 
  $result = uni("username", $username);
  </code></pre>
  
  <p>...i am about to bang my head against something solid. For some reason the query won't return a result and I dont know why.</p>