简体   繁体   中英

Getting this error #1064

When I'm inserting my table empinfo

Query for Insert table

$sql="INSERT INTO empinfo(EmpName,Add,MobileNo)values('$EmpName','$Add','$MobileNo')";

I get the error:

#1064 - 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 'Add,MobileNo)values('jaimin','Baroda','123')' at line 1 

Add is a reserved word within MySQL . If you want to use it as an identifier, then surround it with backticks (as you always should do with identifiers):

$sql="INSERT INTO empinfo(`EmpName`,`Add`,`MobileNo`)values('$EmpName','$Add','$MobileNo')";

Add is a reserved word. If you want to use it as a column name, you have to put it in backticks:

$sql="INSERT INTO empinfo(EmpName,`Add`,MobileNo)values('$EmpName','$Add','$MobileNo')";

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM