开发者

problem with apostrophe

开发者 https://www.devze.com 2023-03-20 20:58 出处:网络
开发者_运维问答I am using mysql with PHP. I have a problem with inserting the apostrophe value in database. However I use -
开发者_运维问答

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()

0

精彩评论

暂无评论...
验证码 换一张
取 消