mysql_real_escape_string 将数据与反斜杠一起存储在数据库中
当我在未转义的字符串上使用 mysql_real_escape_string 时,数据库中的数据存储时带有反斜杠,这是不应该发生的。
我关闭了 magic_quotes_gpc ,不知道为什么会发生这种情况。有什么想法吗?
mysql数据库有什么设置需要修改吗?
我没有在代码中的任何地方使用addslashes。 PHP 语言。
请帮忙。
When i am using mysql_real_escape_string on my unescaped strings the data in the database is storing with the backslashes which should not happen.
I have magic_quotes_gpc OFF not sure why this is happening. Any idea ?
Is there any setting in the mysql database which needs to be modified.
I am not using addslashes any where in the code. PHP language.
Please help.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
magic_quotes 有多种变体,所有这些变体都非常具有侵入性并且无法被覆盖。我认为 DBMS 不太可能完成额外的转义。
您在应用 mysql_real_escape_string() 之前检查过数据是什么样子吗?我敢打赌它已经以某种方式转义了。
C.
There are several variants of magic_quotes all of which are very invasive and cannot be overridden. I think its unlikely that that extra escaping is being done by the DBMS.
Have you checked what the data looks like before applying the mysql_real_escape_string() - I would bet its already escaped somehow.
C.
答案很简单。
mysql数据库中没有需要修改的设置。
这是您的代码/设置。
要么您启用了
magic_quotes_gpc
并且需要对其进行双重检查,或者您的某些代码进行了另一次削减。the answer is simple.
There are no setting in the mysql database which needs to be modified.
It is your code/settings.
Either you have
magic_quotes_gpc
on and it needs to be double-checked, or some of your code does another slashing.让我们知道当您使用 stripslashes 时,您的输入会变成什么。它是否达到所需的格式。这是为了检查您的输入是否有问题。
既然您已经告诉过,如果不应用 mysql_real_escape_string,您的数据将在没有任何 blackSlashes 的情况下存储...并且在应用它之后,您会得到 blackslash...我个人觉得仔细检查您的代码是否在某个地方应用了addslashes。
有些问题......
Let us know when you use stripslashes, what does your input turn into. Does it get into required format. This is to check whether there is something going wrong with your input coming.
Since you have told that without applying mysql_real_escape_string your data gets stored without any blackSlashes... and after applying it you get blackslash... i personally feel double check your code whether you are applying addslashes some where.
Some questions...