当我插入我的表empinfo
时查询插入表
$sql="INSERT INTO empinfo(EmpName,Add,MobileNo)values('$EmpName','$Add','$MobileNo')";
我收到错误:
#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
答案 0 :(得分:1)
Add
是reserved word within MySQL。如果你想用它作为标识符,那么用反引号包围它(你总是应该用标识符):
$sql="INSERT INTO empinfo(`EmpName`,`Add`,`MobileNo`)values('$EmpName','$Add','$MobileNo')";
答案 1 :(得分:1)
Add
是保留字。如果你想将它用作列名,你必须把它放在反引号中:
$sql="INSERT INTO empinfo(EmpName,`Add`,MobileNo)values('$EmpName','$Add','$MobileNo')";