得到此错误#1064

时间:2013-07-24 09:21:26

标签: php

当我插入我的表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 

2 个答案:

答案 0 :(得分:1)

Addreserved 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')";