Jump to content

Call to undefined method PDOStatement::exec()


taveleiro

Recommended Posts

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!

 

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.