problem with apostrophe
I am using mysql with PHP. I have a problem with inserting the apostrophe value in database. However I use -
$newstring = str_replace("'","'",$string);
OR
$newstring = str_replace("'","''",$string);
but how could I fetch the string as it is?
Thanks.
Use mysql_real_escape_string
:
mysql_real_escape_string($string)
you need to escape it, use addslashes()
to sanitise it, or better yet, mysql_real_escape_string()
精彩评论