MySQL cannot insert [err] 1064 – you have an error in your SQL syntax- Laidada

Time:2022-5-30

 

Error [err] 1064 – you have an error in your SQL syntax;

When writing PHP, msyqli inserts data after writing, and the error is always reported. After copying to Navicat, the error is still reported.

[err] 1064 – you have an error in your SQL syntax; Uncomfortable

 insert into order (Oid,user_id,Odate,Onum,Tid,states) values ('1612715211','1612715212','2021-02-01 02:28:02','9','1612715213','2')

All varchar

Later, I checked and said that the keywords using MySQL need to be quoted. Query the website:https://dev.mysql.com/doc/refman/8.0/en/keywords.html#keywords-8-0-detailed-S

Keywords are words that have important meaning in SQL.Some keywords, such asSELECT, DELETEorBIGINT, is reserved and needs to be used as an identifier, such as table and column name special treatment.The same may be true for the names of built-in functions.

My order is the keyword

 insert into 'order' (Oid,user_id,Odate,Onum,Tid,states) values ('1612715211','1612715212','2021-02-01 02:28:02','9','1612715213','2')

Error [err] 1064 – you have an error in your SQL syntax; It is found that the single quotation mark in English is not used, but the ‘in English is the one in the upper left corner of the keyboard

 insert into `order` (Oid,user_id,Odate,Onum,Tid,states) values ('1612715211','1612715212','2021-02-01 02:28:02','9','1612715213','2')

Affected rows: 1
Time: 0.058s

It’s really not easy