Reputation: 1347
I know you can't use the " character, tried ` instead and that didn't work, any ideas?
$sql = $db->prepare('INSERT INTO testDB VALUES(`$title`,`$bodytext`,`$created`)');
Upvotes: 0
Views: 1063
Reputation: 91942
Try this:
$sql = $db->prepare('INSERT INTO testDB VALUES(?, ?, ?)');
$sql->execute(array($title, $bodytext, $created));
What I did was removing the variables from the SQl query and replaced them with ?
as placeholder. You only bind values to the statement at execution time.
The way you tried to do it was no different from using regular SQL queries.
Upvotes: 3