When PHP modifies data from MySql, it is only valid for numeric operations and non-numeric operations. what should I do? _ PHP Tutorial

Source: Internet
Author: User
When PHP modifies data from MySql, it is only valid for numeric operations, and non-numeric operations are invalid. what should I do ?. Problem Description: use PHP to modify data to the MySql database to add, delete, modify (the database can be correctly connected). after testing, the code can only add, delete, and modify numbers, non-numeric operation problem description:

Use PHP to modify data in the MySql database to add, delete, and modify data (the database can be correctly connected). after testing, the code can only perform normal addition, deletion, and modification operations on numbers, the non-numeric operation is invalid, but you need to enter Chinese characters in the course name. what should I do if I modify it? The problematic code is: $ kkxq, $ xs, $ xf )" The code (the code is correct) is as follows:


























(All are guesses) because it is only valid for numbers, there is a problem with the data type transmitted to the database. However, the data type obtained through var_dump ($ kcm) is string. So how to input string variables to the database? Tested:The feasible method is to add single quotation marks to the string variables in this line of code:'$ Kcm', $ Kxq, $ xs, $ xf )" However, I think that variables are parsed using double quotes in PHP, so it is a bit confusing.. It is worth a look: http://www.jb51.net/article/21035.htm from this link, understand some problems. Summary: 1. Summary: variables in double quotation marks can be parsed. single quotation marks are absolute strings. Single quotation marks and double quotation marks must be used in pairs. 2. the '\' backslash in single quotation marks will be directly output, and the backslash in double quotation marks will be parsed as escape characters. PHP complex variables are enclosed in curly brackets, which can be correctly analyzed by the syntax analyzer.. For example: The SQL statement inserted into the database uses single quotes to define strings. To insert a string containing single quotes into the database, use escape characters. Addslashes ()Function: Adds a backslash before a specified predefined character.
Double quotation marks (")
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 Weizhi note (Wiz)



Use PHP to modify data in the MySql database to add, delete, modify (the database can be correctly connected). after testing, the code can only perform normal addition, deletion, and modification operations on numbers, not numeric operations...

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.