2

当我在我的未转义字符串上使用 mysql_real_escape_string 时,数据库中的数据使用不应该发生的反斜杠存储。

我有 magic_quotes_gpc OFF 不知道为什么会这样。任何的想法 ?

mysql数据库中是否有任何设置需要修改。

我没有在代码中的任何地方使用添加斜杠。PHP 语言。

请帮忙。

4

3 回答 3

2

magic_quotes 有几种变体,所有这些变体都非常具有侵入性并且不能被覆盖。我认为 DBMS 不太可能进行额外的转义。

在应用 mysql_real_escape_string()之前,您是否检查过数据的样子- 我敢打赌它已经以某种方式逃脱了。

C。

于 2010-05-14T11:55:47.277 回答
0

答案很简单。mysql数据库中没有需要修改的设置。这是您的代码/设置。

要么你 magic_quotes_gpc,它需要被仔细检查,或者你的一些代码做了另一个削减。

于 2010-05-14T12:21:14.090 回答
0

stripslashes() 是 PHP 指令 magic_quotes_gpc 处于打开状态(默认情况下处于打开状态)时,并且您没有将此数据插入需要转义的位置(例如数据库)。例如,如果您只是直接从 HTML 表单输出数据。

<?php
$str = "Is your name O\'reilly?";

// Outputs: Is your name O'reilly?
echo stripslashes($str);
?>

让我们知道当您使用 stripslashes 时,您的输入会变成什么。它是否进入所需的格式。这是为了检查您的输入是否有问题。

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...

  1. Does this happen only in this current function.
  2. Check your magic_quotes_gpc is on or off.
  3. Can you post a part of that function which is causing this problem.
于 2010-05-14T12:23:41.457 回答