I have read about the issue of automatic escape in PDO. if the prepare and execute methods are used, they can also prevent SQL injection and other attacks. Because all variables are automatically escaped. Then, I enter df 'dfdf & quot; in the form, and no data can be entered in the result. SQL statement: INSERTINTO
I read the book and said that using the prepare and execute methods can also prevent SQL injection and other attacks. Because all the variables will
Automatically escaped.
Then, I enter df 'dfdf "in the form, and no data can be entered in the result.
SQL statement: INSERT INTO cms_manage (admin_user, admin_pass, level, last_time) VALUES ('df 'dfdf "', 'Taobao', '6', NOW ())
Error message: SQLSTATE [42000]: Syntax error or access violation: 1064 You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'dfdf "', 'da39a3ee5e6b4b0d3255bfef95601890afd80709', 'At line 9
When I use the mysql_real_escape_string function to escape the data df 'dfdf ", it will be successful. whether prepare and execute can be automatically escaped or not should be manually escaped.
------ Solution --------------------
Of course!
However, you only post SQL commands and do not use the prepare and execute methods.
------ Solution --------------------
I think it is a problem with your code. the prepare () execute () combination of PDO can indeed prevent SQL injection.
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