taveleiro Posted September 18, 2013 Share Posted September 18, 2013 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! Link to comment https://forums.phpfreaks.com/topic/282263-call-to-undefined-method-pdostatementexec/ Share on other sites More sharing options...
AbraCadaver Posted September 18, 2013 Share Posted September 18, 2013 Maybe because there is no exec() method: http://us2.php.net/manual/en/pdostatement.execute.php Link to comment https://forums.phpfreaks.com/topic/282263-call-to-undefined-method-pdostatementexec/#findComment-1450161 Share on other sites More sharing options...
taveleiro Posted September 18, 2013 Author Share Posted September 18, 2013 Thanks Cracka, highly embarrassed! Last line should have read: $stmt->execute() or die(print_r($db->errorInfo(), true)); Link to comment https://forums.phpfreaks.com/topic/282263-call-to-undefined-method-pdostatementexec/#findComment-1450163 Share on other sites More sharing options...
AbraCadaver Posted September 18, 2013 Share Posted September 18, 2013 Use The Force young taveleiro. Link to comment https://forums.phpfreaks.com/topic/282263-call-to-undefined-method-pdostatementexec/#findComment-1450164 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.