意外标识符Javascript SQL



我试图在javascript中使用vars构建一个sql语句的字符串。

我得到了这行代码

     var sql = "'INSERT INTO UPLOADS (poleID, submitDate, poleDamaged, poleDown, wireDown, brokenFixture, brokenBulb, fullname, phonenumber, email, comments, address, city, state, zipcode, lat, lng) VALUES (" + poleID + "," + submitdate + "," + poleDamaged + "," + poleDown + "," + wireDown + "," + brokenFixture + "," + brokenBulb + "," + fullname + "," phonenumber + "," + email + "," + comments + "," + address + "," + city + "," state + "," + zipcode + "," + lat + "," + "," + lng + ")" + "'";

和我的谷歌Chrome开发工具控制台抛出这个错误,并指向上面的行

Uncaught SyntaxError: Unexpected identifier 

抛出这个错误的原因是什么?

试试这个。你漏掉了两个地方的+和一个额外的逗号…

 var sql = "'INSERT INTO UPLOADS (poleID, submitDate, poleDamaged, poleDown, wireDown, brokenFixture, brokenBulb, fullname, phonenumber, email, comments, address, city, state, zipcode, lat, lng) VALUES (" + poleID + "," + submitdate + "," + poleDamaged + "," + poleDown + "," + wireDown + "," + brokenFixture + "," + brokenBulb + "," + fullname + "," + phonenumber + "," + email + "," + comments + "," + address + "," + city + "," + state + "," + zipcode + "," + lat + "," + lng + ")" + "'";

最新更新