This article describes the functions commonly used to escape special characters in php mysql programming, including the usage of mysql_escape_string and addslashes functions. For more information, see. Functions for escaping special characters in php mysql Function 1 is mysql_escape_string, and function 2 is addslashes. The difference between mysql_escape_string and addslashes is that mysql_escape_string always converts "'" to "\".Addslashes converts "'" to "when magic_quotes_sybase = on. When magic_quotes_sybase = off, convert "'" to "\'" php. some functions are provided to make the query statement meet the requirements. for example, mysql_escape_string references a string and returns a result, this result can be used as a properly escaped data value in an SQL statement. A string is enclosed by single quotes and returned, where each single quotation mark ("'"), backslash ("\"), ascii nul, and Control-Z appear in the string, A backslash is added before the character. If the parameter is NULL, the result value is the word "NULL" without single quotes ". QUOTE function is added in MySQL 4.0.3. We recommend that you read: php character escape function reference, php regular expression escape character example, hope to help you understand the handling methods of intermediate and special characters in php programming. When writing data to a database, sometimes the string to be written contains some special characters, such as ',', //, %, etc, I don't know if mysql has such escape functions, not those APIs. |