Call to undefined method PDO::execute()

->execute() is for prepared statements. e.g.

$stmt = $dbh->prepare('some query here');
$stmt->execute();

You’re trying to execute a query directly on the main DB object. For PDO, that means

 $dbh->exec('query goes here');

You really should look into prepared statements. You’re vulnerable to SQL injection attacks as is, and since you’re using PDO to begin with, it’s basically unforgivable to NOT be writing safe queries.

Leave a Comment