Php + mysql how to store html code to the database? Php & nbsp; + & nbsp; mysql & nbsp; how to store html code to the database? What should I pay attention? What type is used for database fields? How does php handle html code? & Lt ;? Php & nbsp; $ html_cod php + mysql how to store html code to the database?
Php + mysql how to store html code to the database?
What should I pay attention? What type is used for database fields? How does php handle html code?
$ Html_code ='Hello world
';
// Database table
Part_name | html_code
Hello | ??
?>
------ Solution --------------------
Tinytext can contain a maximum of 255 (2 ^ 8-1) characters.
Text can contain a maximum of 65535 (2 ^ 16-1) characters.
Mediumtext can contain a maximum of 16777215 (2 ^ 24-1) characters.
Longtext can contain a maximum of 4294967295 (2 ^ 32-1) characters.
Select based on situation
------ Solution --------------------
There are two positive solutions upstairs,
Supplement:
1. Save the new string to the database.
2. the field must be of the string type, including text and varchar (the length must be sufficient.
3. when you read data from the database, remember to use the htmlspecialchars function for processing. Otherwise, the received string will be html code.