PHP content into the database needs mysql_escape_string processing
Mysql_escape_string (PHP 4 >= 4.0.3, PHP 5, Note: This method has been deprecated in PHP5.3, not recommended) mysql_escape_string--Escapes a string for mysql_query String mysql_escape_string (string unescaped_string) This function escapes unescaped_string so that it can be used safely for mysql_query (). Note: mysql_escape_string () does not escape% and _. This function andmysql_real_escape_string () is exactly the same, except that mysql_real_escape_string () accepts a connection handle and transfers the string in accordance with the current character set. The mysql_escape_string () does not accept the connection parameters, and regardless of the current character set settings. Example 1. Mysql_escape_string () Example <?php$item = "Zak ' Laptop"; $escaped _item = mysql_escape_string ($item);p rintf ("escaped String:%s\n ", $escaped _item);? > Output: Escaped string:zak\ ' s Laptop
use Htmlentities when content is displayedThe Htmlentities () function converts a character to an HTML entity. This means that the data that is taken out does not cause syntax errors because it conflicts with its HTML.
PHP content inserted into the database requires mysql_escape_string to handle the display when using Htmlentities