This occurs when magic_quotes_gpc is enabled. The reason is that thinkphp does not judge whether magic_quotes_gpc is enabled when it comes to the database, regardless of the escape processing in November 21.
The solution is to add the following code to the entry file:
if (!get_magic_quotes_gpc()) { function addslashes_deep($value) { $value = is_array($value) ? array_map('addslashes_deep', $value) : addslashes($value); return $value; } $_POST = array_map('addslashes_deep', $_POST); $_GET = array_map('addslashes_deep', $_GET); $_COOKIE = array_map('addslashes_deep', $_COOKIE); $_REQUEST = array_map('addslashes_deep', $_REQUEST);}
Someone modified the escape Function in dbmysql. Class. php as follows:
public function escape_string($str) {if (get_magic_quotes_gpc()) {return $str;}if($this->_linkID) {return mysql_real_escape_string($str,$this->_linkID);}else{return mysql_escape_string($str);}}
This method is not available! Because if the magic function on, and $ STR is not post or get (such as reading text or database), it still does not add a backslash.
Therefore, no matter whether $ STR has been escaped or not, I will first remove the escape and then add the escape. This avoids the second escape and the omission escape.
The following is my modification method:
public function escape_string($str) {$str = stripslashes($str);if($this->_linkID) {return mysql_real_escape_string($str,$this->_linkID);}else{return mysql_escape_string($str);}}
Article Source: http://www.thinkcart.net/thinkphp-escape-string-110.html