title: Function giving correct answer in one case, not in any others
body: <p>Below is the function I am using. It is strange because when I test the name "admin" it returns an associative array with all the correct columns and values, however every other name tests returns 0 as far as I can tell, meaning nothing is found from the query (I am entering the names perfectly as they are in the database).</p>
  
  <p>I have a feeling this could be some sort of security feature of pdo or something but I don't understand why it is acting up this way.</p>
  
  <p>I am using mysql.</p>
  
  <p>Does anyone know the problem and how to resolve it? Thank you!</p>
  
  <pre><code>function getUserDetailsByName($name, $fields = "*")
  {   
      $db = connect_db();
  
      $query = "SELECT $fields FROM UserDetails WHERE userName=:username";
      $result = $db-&gt;prepare($query);
      $result-&gt;bindParam(":username", $name);
  
      if (!($result-&gt;execute())) {
          sendMessage (1,1,'Query failed',$query);
          $db = null;
          return;
      }
      if (!($result-&gt;fetch(PDO::FETCH_NUM) &gt; 0)) {
          $db = null;
          return 0;
      }else{
          $result = $result-&gt;fetch();
          $db = null;
          return $result;
      }   
  }
  </code></pre>
  
  <p>EDIT: Someone asked to post how I call the function.</p>
  
  <pre><code>$user = getUserDetailsByName($_POST['value']);
  if($user == 0)
  {
    print "user = 0";
  }
  print_r($user);
  </code></pre>