Single and double quot into database

He said "I can't"

The above is the value of $myVar.

I like to update the column named “say” in my table “test” of my database with the value above.

The code below is one of the trials for it, but I failed.

[b]trial code1[/b]

$myVar=[COLOR="#FF0000"]"[/COLOR]he said "I can't"[COLOR="#FF0000"]"[/COLOR];
mysql_query("UPDATE test SET say = '$myVar' WHERE n=1 ");

How can I update it successfully?

There are a few ways, the first being to use prepared statements, the second is to use [url=http://us.php.net/manual/en/function.mysql-real-escape-string.php]mysql_real_escape_string

Utilizing the second method your code would become

$myVar=mysql_real_escape_string("he said \\"I can't\\"");
mysql_query("UPDATE test SET say = '$myVar' WHERE n=1 ");