I have designed a comment system. This is what I am basically doing.
$story=$_POST['story'];
$story=mysql_real_escape_string($story);
$query = "INSERT INTO `comment` VALUES('$story')";
Now the problem is when i store the comment all the "
are replaced by \"
and all the '
are replaced by \'
. So when I display the comments back these \
also show up in the comment.
Another problem is that &
disappears. eg: if user comments I & you
only I
is stored into the database.
In fact in few cases comments don't even enter the database.
What is the correct way of processing & storing user comments so that you can display them back as written originally?
PS: I am not worried about sql injection. I just want comments to show up the way they were entered.