What's wrong with seeing me? it's been two days.

Source: Internet
Author: User
What's wrong with me? $ SQL & nbsp; INSERT & nbsp; INTO & nbsp; patient & nbsp; (order, name, age, sex, tel, qq, disease, media_from, area, ordertime, teshuyaoqiu, content, ordertag, beizhu, zixun_id) VAL

$ SQL = "INSERT INTO patient (order, name, age, sex, tel, qq, disease, media_from, area, ordertime, teshuyaoqiu, content, ordertag, beizhu, zixun_id) VALUES ('$ order',' $ name', '$ age',' $ tel ',' $ QQ', '$ disease', '$ media_from ', '$ region',' $ ordertime', '$ teshuyaoqiu', '$ content',' $ ordertag ',' $ beizhu', '$ zixun_id ')";

If (mysql_query ($ SQL, $ conn )){
Exit ('added successfully! Click here on the homepage ');
} Else {
Echo 'Sorry! Failed to add data: ', mysql_error (),'
';
Echo 'click here to return retry ';
}



Running result:
Sorry! Failed to add data: 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 'Order, name, age, sex, tel, qq, disease, media_from, area, ordertime, teshuyaoqiu, content, 'At line 1
Click here to return and try again
------ Solution ----------------------
Order is a reserved mysql word, which should be escaped during other operations
'Order'
------ Solution ----------------------
Two problems
1. order is the keyword. it is best not to use it.
To use it, use.
2. the number of insert fields does not match the number of values.
15 fields, but only 14 values, less sex

Change to this.
$ SQL = "INSERT INTO patient ('order', name, age, sex, tel, qq, disease, media_from, area, ordertime, teshuyaoqiu, content, ordertag, beizhu, zixun_id) VALUES ('$ order',' $ name', '$ age',' $ sex', '$ tel', '$ QQ',' $ disease ', '$ media_from', '$ region',' $ ordertime ',' $ teshuyaoqiu ',' $ content', '$ ordertag', '$ beizhu',' $ zixun_id ') ";

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.