title: prepared statement PDO Probably small mistake
body: <p>im rewriting all my database queries so that they are prepared and with PDO (before I used mysqli) so that they are save against sql injections. Now I'm new to PDO so its probably a small mistake that I dont see, so I hope u guys can help me out because this code doesnt work.  </p>
  
  <pre><code> &lt;?php
  
          function getUserBalance($steamid)
          {
              include 'settings.php';
  
              $conn = new PDO("mysql:host="$servername";dbname="$dbname"", $username, $password);
              $conn-&gt;setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); 
  
  
  
              $sql = $conn-&gt;prepare("SELECT balance FROM users WHERE steamid= :steamid");
  
  
              $stmt = $conn-&gt;prepare($sql); 
              $stmt-&gt;bind_param(":steamid", $steamid, PDO::PARAM_STR);
              $stmt-&gt;execute(); 
  
  
  
              while($row = $stmt-&gt;fetch(PDO::FETCH_ASSOC)) 
              { 
                  return $row['balance'];
              } 
  
          }
           $stmt-&gt;close();
  
  
      ?&gt;
  </code></pre>