I've just started learning aboud PDO and prepared statements (which sure seem to beat remembering to use mysql_real_escape_string() every time) but I'm having trouble getting the script to execute properly:
<?php
error_reporting(E_ALL);
echo "start";
try{
$dbh=new PDO('mysql:host=localhost;dbname=DBNAME','USER','PWD');
}
catch(PDOException $e){
echo 'Error connecting to MySQL!: '.$e->getMessage();
exit();
}
$dbh->prepare('SELECT * FROM users WHERE uid= ?');
$dbh->execute(array('15400743'));
$result=$dbh->fetchAll();
print_r($result);
echo "end";
?>
This is pretty much copied from example code, but when executed only returns "start". I've double-checked my db/user/pw. Anything else people see wrong? Thanks!