Answer the question
In order to leave comments, you need to log in
Why doesn't PDO work?
If you run the query with a regular PDO query, then it works:
$char = $page->for;
foreach( $_POST as $key => $value ){
$value = str_replace("'", "\'", $value);
$connect->query("UPDATE `keys` SET `value` = '$value' WHERE `name` = '$key' AND `for` = '$char'");
}
$char = $page->for;
$query = $connect->prepare("UPDATE keys SET value = :v WHERE name = :n AND for = :c");
$query->bindParam(':c', $char);
foreach( $_POST as $key => $value ){
$query->bindParam(':v', $value);
$query->bindParam(':n', $key);
$query->execute();
}
Answer the question
In order to leave comments, you need to log in
Because KEYS, VALUE, NAME and FOR are MySQL reserved words . If you want to use them as table or field names, use backticks.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question