How to insert a backslash in MySQL, a backslash is eaten, and a backslash is escaped
Problem Description:
After the contents of the backslash in MySQL are put into storage, the backslash is found to be missing for no reason (as the old saying is eaten)
Example: inserting INSERT into TB (' URL ') VALUES (' absc\eeee '); The results in the database are: absceeee (the backslash is gone)
In this detail, I believe we all know the problem, see the solution below.
Solution:
Use Addslashes (), mysql_escape_string () and other functions for processing, that is, before inserting the database, the content is processed
such as: $CC = addslashes (' absc\eeee '); INSERT into TB (' URL ') values ($CC);
Suddenly found good also, there is no. But what happened in the middle, do you know, and then look down-""
What happened:
When MySQL inserts the database, it automatically removes the escape character, the backslash "\", Addslashes (), and mysql_escape_string () uses these functions to add a backslash before the backslash, which is the absc\\eeee. In the storage when the first backslash is considered to be an escape character, the second backslash is considered to be normal content, so remove the first backslash, keep the second one, see the result is the backslash inserted.
Go
How to insert a backslash in MySQL, a backslash is eaten, and a backslash is escaped (go)