0

I try to Insert a word into a database using PHP:

for example $productnaam = je t'aime; (I love u in french) This won't work because when updating productnaam I need to put accents arround '$productnaam' like so. Is there any way I can fix this?

$query = "UPDATE products2
SET hoofdcategorie1 = '$hoofdcategorie1',
subcategorie2 = '$subcategorie2',
subcategorie3 = '$subcategorie3',
artikelnummer = '$artikelnummer',
productnaam = '$productnaam',
infotext = '$infotext',
hoeveelheid = '$hoeveelheid',
eenheidsprijs = '$eenheidsprijs'
WHERE id = '$id'";

Kind regards, PJ

PJ_DL
  • 1
  • 1
  • 1
    Use prepared statements (for instance with [PDO](https://www.php.net/manual/en/pdo.prepared-statements.php)). Will also fix your code's SQL injection vulnerability in the process. – Jeto Sep 20 '20 at 15:24
  • Thank you, this solved my problem! – PJ_DL Sep 20 '20 at 16:03

0 Answers0