title: get results from MSSQL prepared statement
body: <p>This code prints out a list of column names. But I would expect it to print out the information stored in the <code>UserName</code> table for the user with the <code>LoginName</code> of JSmith.</p>
  
  <pre><code> $loginname = "JSmith";
   $stmt = $dbh-&gt;prepare("SELECT * FROM UserName WHERE LoginName=:login_name");
   $stmt-&gt;bindValue(":login_name", $login_name, PDO::PARAM_STR);
   $stmt-&gt;execute();
  
  echo "&lt;table&gt;&lt;tr&gt;";
  $result = $stmt-&gt;fetch(PDO::FETCH_ASSOC);
   print_r($result);
  foreach ($result as $key =&gt; $val){
      echo "&lt;th&gt;" . $key . "&lt;/th&gt;";   
  }
  echo "&lt;/tr&gt;";
  echo "&lt;/table&gt;";
  </code></pre>
  
  <p>Why doesn't this return the row with the users name? Looking at <code>echo gettype($result)</code> shows me that they are strings and integers; not like each piece of the returned array is itself an array. I'm sure it's a simple thing, but any help is appreciated. Thanks!</p>