-4

can i update table and set JSON string with PDO? Because PDO is removing "\" character and diacritics is not working please help.

->query("UPDATE products SET name = '".$new_name."' WHERE shop = '1' AND id = 'a9t8'");
  • Read this [answer](http://stackoverflow.com/a/60496/2864740). It will Fix/Avoid the Problem (and it might reveal an additional problem with encoding), which is why I've marked it as a duplicate. – user2864740 Apr 27 '14 at 18:38

1 Answers1

1

You are using PDO yet still open to SQL injection.

You should prepare your query, that's the whole point of PDO

$sql = "UPDATE products SET name = :new_name WHERE shop = :shop AND id = :id";
$statement = $conn->prepare($sql);
$statement->bindValue(":new_name", $new_name);
$statement->bindValue(":shop", '1');
$statement->bindValue(":id", 'a9t8');
$statement->execute();
meda
  • 45,103
  • 14
  • 92
  • 122