Qasim
Qasim

Reputation: 1704

PDO::execute() is an undefined method for me?

Here is the PDO code in question:

$db->prepare("INSERT INTO user (id, name, password, salt, email, join_date, chats)
              VALUES (NULL, ?, ?, ?, ?, ?, ?)");
$db->execute(array($name, $password, $salt, $email, $joindate, ''));

I get the fatal error: Fatal error: Call to undefined method PDO::execute() in register.php on line 12, line 12 being the execute above. What could be wrong? The array contains perfect strings, checked them with a print_r.

Upvotes: 10

Views: 13931

Answers (1)

Dan Grossman
Dan Grossman

Reputation: 52372

PDO::prepare returns a PDOStatement object which has the execute method.

$st = $db->prepare(...);
$st->execute(...);

Upvotes: 33

Related Questions