I do an insert to database using this and this example, but I've got an error message: Call to a member function execute() on a non-object.
If I do INSERT INTO participants(email) VALUES ('$email')
evrething is OK. Where is my mistake?
$pdo = new PDO('sqlite:participants.db');
$insert = $pdo->prepare("INSERT INTO participants(email) SELECT $email WHERE NOT EXISTS(SELECT 1 FROM participants WHERE email = $email);");
$insert->execute();
UPD:
This is what var_dump($insert)
gives:
object(PDOStatement)#2 (1) {
["queryString"]=>
string(65) "INSERT INTO participants (email) VALUES ('paekov@gmail.com')"
}