Saving and retrieving content with apostrophes and double quotes

How do you save and retreive content with apostrophes and double quotes?

I am using escape and mysql escape to parse the apostrophes and double quotes…

But that is breaking the content in two.



$id = 1;
$newcontent = mysql_escape_string($content);

$insertseed = "Insert INTO thistable (id, content ) VALUES ($id, '$newcontent')"; 


A sentence like
“It’s mind and yours.” gets broken into “It”

This part is not saved –> “s mind and yours.”

Any ideas ?

Odd, as that’s exactly the type of thing mysql_escape_string() is meant to prevent. I’m guessing there’s more to your code that you didn’t show?

Hey marcel
Try to view page source of generated page.
And get a habit of using htmlspacialchars() for the form field values

Just as a side point, you should use mysql_real_escape_string() - the following is from the documentation of mysql_escape_string():

WarningThis function has been DEPRECATED as of PHP 5.3.0 and REMOVED as of PHP 6.0.0. Relying on this feature is highly discouraged.
I don’t know if having the single quotes in the string affects it when you put the variable straight in the string, because I always concatenate, but that could be it perhaps?

Try

$id = 1;
$insertseed = "Insert INTO thistable (id, content ) VALUES (" . $id . ", '" . mysql_real_escape_string($content) . "')"