Possible Duplicate:
Can you put placeholders in select part of a query using PDO?
I don’t like to ask so ‘simple’ questions, but this code is not working and I cannot figure out why after 1 hour trying ($this->DB is working without problem).
This code doesn’t work:
$STH = $this->DB->prepare("INSERT INTO chapters (subject_keyword, type, ?) VALUES (?, 'Introduction', ?)");
$STH->execute(array($this->Language, str_replace(' ', '_', $Title), $Introduction));
print_r($STH->ErrorInfo());
Nor the expanded form:
$t_lang = $this->Language;
$t_title = str_replace(' ', '_', $Title);
$t_intr = $Introduction;
$STH = $this->DB->prepare("INSERT INTO chapters (subject_keyword, type, ?) VALUES (?, 'Introduction', ?)");
$STH->execute(array($t_lang, $t_title, $t_intr));
print_r($STH->ErrorInfo());
And the returned error is:
DDC: 164Array ( [0] => 42000 [1] => 1064 [2] => You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ”en’) VALUES (‘Test_tittle’, ‘Introduction’, ‘
\r\n This is the introduction t’ at line 1 )
That error doesn’t indicate much for me, as these few mysql lines seem right except maybe for the \r\n. But I’ve also tried to do htmlentities($Introduction) and few other things with no luck. All the variables here are set and with some not-null value.
Try: