I currently have the following code:
$dbh = new PDO('mysql:host='.DATABASE_HOST.';dbname='.DATABASE_NAME, DATABASE_USER, DATABASE_PASSWORD);
$dbh->setAttribute(PDO::ATTR_EMULATE_PREPARES, false);
$dbh->prepare("INSERT INTO mdr_contacts SET fkRelatieId = 0, reseller = 0, code = :code, naam = :naam");
$dbh->execute(array(":code" => $contact["contact_id"],":naam" => $name));
However this seems to fail: Fatal error: Call to undefined method PDO::execute() in file.php on line 67
What i've done so far to make this work:
$name and $contact exists and has the right value.But none of this works, can anyone set me in the right direction?
You execute a statement, not a connection. prepare() on a connection, returns a statement.
Also, I prefer to explicitly call bind on values, but this is just my OCD prefs.
$statement = $dbh->prepare("INSERT INTO mdr_contacts SET fkRelatieId = 0, reseller = 0, code = :code, naam = :naam");
$statement->bindValue(":code", $contact["contact_id"]);
$statement->bindValue(":naam", $name);
$statement->execute();
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With