I just started learning aboud PDO and prepared statements (which seem to be memorable to me to use mysql_real_escape_string () every time), but I had problems with the script working correctly:
<?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 the sample code, but only "start" is returned when executed. I double checked my db / user / pw. Anything else people see wrong? Thanks!
source
share