pdo php
-
Can anyone find an error in this query ?
try {
$dbh = new PDO(' ….. ');
$stmt = $dbh->prepare('INSERT into customer (name) values (:name)');
$stmt->bindParam(':name', 'lilly');
$stmt->execute();$dbh = null;
} catch (PDOException $e) {
print "Error!: " . $e->getMessage() . "
";
die();
}It doesn't display any error and neither does it perform the insert?? Thanks
-
Can anyone find an error in this query ?
try {
$dbh = new PDO(' ….. ');
$stmt = $dbh->prepare('INSERT into customer (name) values (:name)');
$stmt->bindParam(':name', 'lilly');
$stmt->execute();$dbh = null;
} catch (PDOException $e) {
print "Error!: " . $e->getMessage() . "
";
die();
}It doesn't display any error and neither does it perform the insert?? Thanks
Strange, when I run the code I get this error message: Fatal error: Cannot pass parameter 2 by reference in ... If you look at the PDOStatement::bindParam() documentation, the second argument is passed by reference, so I guess you can't pass a literal value by reference.