PHP processes HTML data in MySQL

Source: Internet
Author: User
Some people say that you should be careful when storing HTML in MySQL. But what should you pay attention? Some people say that you should be careful when storing HTML in MySQL. But what should you pay attention?

Reply content:

Some people say that you should be careful when storing HTML in MySQL. But what should you pay attention?

SQL injection .........

When MySQL stores HTML code:
1. Use PDO preprocessing to prevent SQL Injection
2.html code should be converted to html entities to prevent XSS attacks
3. If possible, directly filter out the "script" and "script" tags.

0. Security Issues agree that shopex is generally used to deal with these two types of attacks. Use PDO preprocessing to prevent SQL injection and XSS attacks to remove all《script》《script》Labels and labelson*Andjavascript:Url, which can be solved by using HTMLPurifier
1. Because you store html, problems may occur during output. On stackoverflow, someone needs to process the output in tags because the html format is stored.
2. Another problem is that you need to pay attention to the html data format. Considering that html data is usually stored in a large amount, large data volumes are usually supported.blobAndtext, Usually recommendedtext, Big data also hasMEDIUMTEXT
3. It is also because of the problem of html data size. Considering the memory size, if there is a large amount of data, we need to compress the data (here is the advice of MySQL Expert on quora)

The most important thing is to prevent SQL injection and XSS attacks.

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.