Php + mysql how to save the content without escaping the original content this post was last edited by ycyuyuan at 20:48:07, January 10
I don't know if php + mysql can save or update the records in the database without using SQL. if you want to use SQL, consider saving the special characters or SQL injection, is there any method to save without escaping as is (there is no SQL Injection Vulnerability)
Items that need to be saved as they are:
For example, to save a long random key
Save a code snippet
Save the php file to the database
Save your own technical articles
Save news ......
Reply to discussion (solution)
Mysql stores the escape characters and reads the reverse meanings automatically.
Mysql_real_escape_string ();
The escape character "'" is required, because the single quotation marks in the string enclosed by single quotation marks may cause ambiguity.
Whether other content needs to be processed depends on your business needs.
Single quotation marks, double quotation marks, backslash, and null must be escaped. If not escaped, the SQL statement may be ambiguous.
Use addslashes for escape during saving, and use stripslashes to reverse the meaning when getting the content.
This is a good question. Solved my confusion about escape.
Solved, because the beginner does not know that mysql_real_escape_string reads the reverse definition automatically, and now the test has finally learned.
If the test is done locally, the test fails on the customer's virtual host space. the read operation does not automatically reverse the definition.
Content submitted for the Space Test:
After the update, the read display becomes:
Content submitted for local test:
After the update, the read display becomes:
It turns out that the ini configuration is different.