Quantcast
Channel: PHP Freaks: PHP Help
Viewing all articles
Browse latest Browse all 13200

Call to undefined method PDOStatement::exec()

$
0
0

LAMP environment, PHP 5.4.13, MySQL 5.5.30.

 

Code snippet:

$db = new PDO('mysql:host=localhost;dbname=test',$username,$password);
$sql="INSERT INTO `atable`(
`user`,  
`expires`, 
`approved_by`,...
VALUES (
:auser, 
:aexpires, 
:aapproved_by,...
)";
$db->setAttribute(PDO::ATTR_EMULATE_PREPARES, false);
$stmt = $db->prepare($sql);
$stmt->bindValue(':auser', $buser, PDO::PARAM_STR);
$stmt->bindValue(':aexpires', $bexpires, PDO::PARAM_STR);
$stmt->bindValue(':aapproved_by', $bmyNull, PDO::NULL_EMPTY_STRING);
...
$stmt->exec($sql) or die(print_r($db->errorInfo(), true)); 
 
Error:
Fatal error: Call to undefined method PDOStatement::exec() in ...
 
Any insights greatly appreciated!

 


Viewing all articles
Browse latest Browse all 13200

Trending Articles