我正在尝试使用以下查询将数据输入我的MySQL数据库
UPDATE `Customer Table` SET `ID`=$ID, `First name`='$FirstName',`Last name`='$LastName',`Home phone number`=$HomePhoneNumber,`Mobile phone number`=$MobilePhoneNumber,`House number`=$HouseNumber,`House name`='$HouseName',`Street name`='$StreetName',`Town name`='$TownName',`Post code`='$PostCode' ,`Notes`='$Notes' WHERE ID=$ID
当我从一个PHP文件调用它但在我从API PHP文件中调用它时不能正常工作时,这工作正常。
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 '`House number`=0,`House name`='43',`Street name`='Westbury',`Town name`='We' at line 1
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 '`House number`=0,`House name`='3',`Street name`='Close',`Town name`='Thorn' at line 1
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 '`House number`=0,`House name`='flat',`Street name`='2 road',`Town ' at line 1
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 '`House number`=0,`House name`='39',`Street name`='valley',`Town name`='',`' at line 1
任何人都可以看到错误的位置,因为我正在努力找到它。从我能看到的所有数据类型都是正确的。
先谢谢,卢克。
答案 0 :(得分:1)
试试这个。您的变量$MobilePhoneNumber
似乎包含其中的字符串部分,例如 +
"UPDATE `Customer Table` SET `ID` = '$ID', `First name` = '$FirstName',
`Last name`= '$LastName',`Home phone number`= '$HomePhoneNumber',
`Mobile phone number` = '$MobilePhoneNumber',`House number` = '$HouseNumber',
`House name`='$HouseName',`Street name`='$StreetName',`Town name`='$TownName',
`Post code`='$PostCode',`Notes`='$Notes' WHERE ID=$ID"
答案 1 :(得分:0)
Gordon Linoff建议最好,$ MobilePhoneNumber没有从我的XML文件中读取。+ "<MobilePhoneNumber>" + MobileNumber + "</MobileNumber>
正在编写而不是+ "<MobilePhoneNumber>" + MobileNumber + "</MobilePhoneNumber>