user3371049 user3371049 - 1 year ago 58
MySQL Question

Issue with the character: ' (single quotation) when trying to save to mySql

When ever there is this character in a string I try to save: ' (single quotation) - it does not save. No error is generated. I need help to understand what is wrong. My character set must accomodate French characters. Otherwise everything works well.

header ('Content-type: text/html; charset=utf-8');



$articleid = $_POST['articleid'];
$contenu = $_POST['editabledata'];
$name = $_POST['name'];

UPDATE al_articles SET $name='$contenu'
WHERE (ArticleID='$articleid')

") or die(mysql_error());


Answer Source

Use addslashes

$articleid  = addslashes($_POST['articleid']);
$contenu  = addslashes($_POST['editabledata']);
$name  = addslashes($_POST['name']);
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download