PHP: PDOStatement simple MySQL Select doesn't work.
        Posted  
        
            by Alan
        on Stack Overflow
        
        See other posts from Stack Overflow
        
            or by Alan
        
        
        
        Published on 2010-03-24T04:15:44Z
        Indexed on 
            2010/03/24
            4:23 UTC
        
        
        Read the original article
        Hit count: 423
        
Hi
I have the following PHP code doing a very simple select into a table.
$statement = $db->prepare("SELECT * FROM account WHERE fbid = :fbid");
$statement->bindParam(":fbid",$uid, PDO::PARAM_STR,45);
$out = $statement->execute();
$row = $statement->fetch();
$out is true (success) yet $row is null.
If I modify the code as follows:
$statement = $db->prepare("SELECT * FROM account WHERE fbid = $uid");
$out = $statement->execute();
$row = $statement->fetch();
$row contains the record I'm expecting.
I'm at a loss. I'm using the PDO::prepare(), bindParams() etc to protect against SQL Injection (maybe I'm mistaken on that).
Please halp.
© Stack Overflow or respective owner