0

I have troubles when I use "PDO prepare" :

$sql ="INSERT INTO table (id, reponse_id_num_quest  , reponse__rep, reponse__commentaire) VALUES (:id, :id_quest, :val, :comm)";
$res=$db->prepare($sql);
$res->bindParam(':id',$idUniq);
$res->bindParam(':id_quest',$ids[$index]);
$res->bindParam(':val',$val);
$res->bindParam(':comm',$commentaire, PDO::PARAM_STR);
$res->execute();

When the variable "$commentaire" contains a string with quote " ' " or backslash, the query insert backslash before the special character.

Ex:

Original string : I don't

In base string : I don\'t

So, on the final HTML view, the string isn't the original.

How could I insert correctly ? Thanks

Yvan
  • 61
  • 4
  • Find out where the slashes are coming from. As in: debug your code and environment. – PeeHaa Jun 28 '16 at 10:23
  • I have fixed it. I have create an .htaccess with this content : php_flag magic_quotes_gpc Off – Yvan Jun 28 '16 at 12:21

0 Answers0