Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

Tags:

php

mysql

pdo

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.

like image 418
Qasim Avatar asked Aug 06 '11 01:08

Qasim


1 Answers

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

$st = $db->prepare(...);
$st->execute(...);
like image 65
Dan Grossman Avatar answered Sep 28 '22 21:09

Dan Grossman