The example in this article describes the solution to two backslash escapes and database class escapes when ThinkPHP is imported into the database. Share it with everyone for your reference. The specific method is as follows:
This happens when magic_quotes_gpc is turned on. The reason is that thinkphp did not determine whether magic_quotes_gpc was turned on when importing it into the database, and escaped it regardless.
The solution is to add the following code to the entry file:
Someone modified the escape function in DbMysql.class.php like this:
In fact, this method is not advisable! Because if the magic function is on and $str is not obtained by post or get (such as reading text or database), it still does not add a backslash.
So regardless of whether $str has been escaped, I always remove the escape first and then add the escape. This avoids double escaping and missing escapes.
Here’s how I modified it:
I hope this article will be helpful to everyone’s ThinkPHP framework programming.
It has nothing to do with the database, it has to do with the PHP insert statement. Check the insert statement. Some of it must be changed and some may not be
If you don’t escape, you won’t be able to insert into it. An error will be reported
But single quotes are still disgusting, so you need to add an extra single quote to change the meaning