mysql_real_escape_string and single quote

后端 未结 6 1421
花落未央
花落未央 2020-12-10 19:07

I\'m quite frustrated. I want to be able to insert into my database names with single quotes - for example, O\'Connor.

So, when inserting into the DB, I do:

6条回答
  •  余生分开走
    2020-12-10 19:57

    I dont check for get_magic_quotes_gpc is on/off.

    I just do $lname = mysql_real_escape_string(stripslashes($_POST['lname'])); so if there is not any quoted text it wont strip slashes.. if there is quoted it will strip them off.

    and it works wonders for me!

提交回复
热议问题