What are the errors of this insert record statement? What should I do?

Source: Internet
Author: User
What are the errors of this insert record statement? I have a place to insert a database record with the error: insertintoreceept (rent, deposit, paidup, createdtime, depositback, coperator) values (50, 1, 51) What is the error in the insert record statement?
I have a place to insert a database record with the following error:
Insert into receept (rent, deposit, paidup, createdtime, depositback, coperator) values (50, 1, 51, '2017-04-10 17:44:47 ', '0', 'zxy ') 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 '17: 44: 47 'at line 1

The time is obtained from $ dt = date ("Y-m-d H: I: s.
I checked this record and it has actually been inserted into the receipt table.

The following is a useful table structure copied from phpmyadmin:
The field type is null. the default value is extra.
Id int (11) no AUTO_INCREMENT
Rent float no none
Deposit float No
Paidup float no none
Depositback varchar (1) No none
Createdtime datetime no none
Coperator varchar (30) no none
Dbtime datetime is NULL
Dboperator varchar (30) is NULL

Why can I still insert a successful error?
What does this error mean?

------ Solution --------------------
It should not be wrong.
I suspect that createdtime is of the date type, rather than datetime. because the date type only accepts 2012-04-10 before 17:44:47. The datetime type is accepted 17:44:47

Although it is the query result of phpmyadmin, it is recommended that you run the following SQL statement
Show create table 'receipt ';
View Results
------ Solution --------------------



You can paste the SQL statements assembled in the $ database class.
------ Solution --------------------
No such strange thing happened.
I did a test. the same table structure and the same SQL statement did not encounter any problems.
------ Solution --------------------
The test is normal. Note that
$ Rent, $ deposit, $ total, and '$ dt' values must exist. if they do not exist, an SQL statement is faulty. Cause error.
------ Solution --------------------
Column count doesn't match value count that is your writing error, such as insert into tablename (a, B, c) VALUES ('avalue ', 'bvalue ') the value of a column is missing. Check the syntax carefully

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.