How does PHP + MySQL store HTML code into a database?

Source: Internet
Author: User
How does PHP + MySQL store HTML code into a database?
What to pay attention to? What type of database fields are used? What does PHP do with HTML code?
 
 Hello World

';//Database Tablepart_name | Html_codehello |?? ?>



Reply to discussion (solution)

The field type is stored directly on the text type.

Tinytext a maximum length of 255 (2^8-1) characters.
Text has a maximum length of 65535 (2^16-1) characters.
Mediumtext a maximum length of 16777215 (2^24-1) characters.
Longtext Maximum length is 4294967295 (2^32-1) characters

See the choice of circumstances

Upstairs two positive solutions,
Add:
1, pay attention to the string of modern deposit database.
2, the field must be a string type, including Text,varchar (must be sufficient length) and so on.
3. When you read from the database, remember to use the Htmlspecialchars function for processing. Otherwise, the received string will be HTML code.

  • Contact Us

    The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

    If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.