inserting data with single quotes

Hi all,

I have the following problem;

if (isset($_POST['opmerkingen'])) {

$opmerking = $_POST['opmerkingen'];


$string = mysql_real_escape_string($opmerking);

		$query = mysql_query("UPDATE tblRegAfwezigheid SET statusAfwId = " . $action . " , opmerking = ".$string." WHERE afwId = " . $afwId);

I have a form with a comment box ("opmerkingen").

I want users to be able to input text there containing single or double quotes.

According to the php documentation I should be able to do this with ‘mysql_real_escape_string()’.

It’s working fine for double quotes, and any string containing double quotes is put into the database. When I try it with a single quote, it doesn’t work though…

EDIT nvm It’s working now. Thanks anyway for the reply.

Use prepared statements instead of mysql_real_escape_string.

You shoud read the Yii guide.