PHP to MYSQL in the data modification operation, only valid for numeric operations, non-numeric operation is not valid, how to do? _php Tutorials

Source: Internet
Author: User
Tags sql injection attack
Problem Description:

Using PHP to modify data in the MySQL database, to implement additions and deletions (the database can be properly connected) tested, the code can only be used for the normal number of additions and deletions, non-numeric operation is invalid but in the course name to enter Chinese, should be modified? The code that has the problem is mainly: < span=""> <> < span=""> , $kkxq, $xs < span=""> , $XF) " < span=""> < span="">The code (the code is correct) is as follows: < span=""> < span="">
< span="">< span="">< span="">
< span="">
<>< span="">< span="">
<>< span="">< span="">
<>< span="">< span="">
<>< span="">< span="">
<>< span="">< span="">
<>
< span="">< span="">

< span="">< span="">< span="">
< span="">
<>< span="">< span="">
<>< span="">< span="">
<>< span="">< span="">
<>< span="">< span="">
<>< span="">< span="">
<>< span="">
< span="">< span="">

< span="">< span="">< span="">
< span="">
<>< span="">< span="">
<>
< span="">< span="">< span="">
< span="">
< span="">< span=""> < span="">Because it is only valid for numbers, it is speculated that there is a problem with the data types passed into the database. However, the data type obtained by Var_dump ($KCM) is a string type. What about passing string variables to the database? tested: A possible way is to add a single quotation mark to the string variable in the line code: < span=""> <> ' $kcm < span=""> ', $kkxq, $xs, $XF) "< span=""> But think, PHP in double quotation marks to parse the variable, so it is a little confusing, so Baidu a bit< span="">。< span="">Worth a look: http://www.jb51.net/article/21035.htm from this link, understand some of the problems. Summarized as follows: < span="">1, Simple summary: The variable in double quotes can be parsed, single quotation marks are absolute strings. Single quotes, double quotes must be used in pairs, 2, the "\" backslash in single quotation marks is output directly, and the backslash in double quotation marks is resolved to escape character. < span="">PHP Complex variables are enclosed in curly braces, and the parser can parse them correctly。 Such as: < strong="">< span=""> < span="">, the SQL statement that is inserted into the database uses single quotation marks to define the string.If you want to insert a string containing single quotation marks into the database, use the escape character. < span=""> the addslashes () function, which functions: Adds a backslash before the specified predefined character.
double quotation mark (")
backslash (\)
Null Http://zh.wikipedia.org/wiki/SQL%E6%B3%A8%E5%85%A5%E6%94%BB%E5%87%BB http ://welcome6.blog.163.com/blog/static/189281346201001694237345/



from the notes (Wiz)



http://www.bkjia.com/phpjc/761103.html www.bkjia.com true http://www.bkjia.com/phpjc/761103.html techarticle problem description: Using PHP to modify data in the MySQL database, to achieve additions and deletions (the database can be properly connected) tested, Code can only be used to correct the number of additions and deletions, non-digital operation ...

  • 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.