我认为一切正常,但它给出了一些简单的mysql语法错误

时间:2016-12-23 10:33:57

标签: php mysql

我不认为应该有任何错误检查并快速响应。

$sql = "INSERT INTO users (Name, Price, SaleDonate, Publisher,Author,PrintedPrice,ImageFront,ImageMiddle,ImageBack,SchoolCollage,Course,Class,City,Code,Part,Category,PosterId,PublishingDate,PostingDate)"
    ." VALUES"
    ." ('$name','$price','$saledonate','$publisher','$author','$printedprice','$imagefront','$imagemiddle','$imageback','$schoolcollage','$course','$class','$city','$code','$part','$category','$posterId','$publishingdate','$postingdate';";

错误是 -

Could not enter data: 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 '' at line 1

我输入的数据不包含任何"

请提前帮助和感谢

2 个答案:

答案 0 :(得分:1)

您应该使用以下查询: -

$sql = "INSERT INTO users (Name, Price, SaleDonate, Publisher,Author,PrintedPrice,ImageFront,ImageMiddle,ImageBack,SchoolCollage,Course,Class,City,Code,Part,Category,PosterId,PublishingDate,PostingDate) VALUES(".$name.",".$price.",".$saledonate.",".$publisher.",".$author.",".$printedprice.",".$imagefront.",".$imagemiddle.",".$imageback.",".$schoolcollage.",".$course.",".$class.",".$city.",".$code.",".$part.",".$category.",".$posterId.",".$publishingdate.",".$postingdate.");";

答案 1 :(得分:0)

$sql = "INSERT INTO users (Name, Price, SaleDonate, Publisher,Author,PrintedPrice,ImageFront,ImageMiddle,ImageBack,SchoolCollage,Course,Class,City,Code,Part,Category,PosterId,PublishingDate,PostingDate) VALUES ('$name','$price','$saledonate','$publisher','$author','$printedprice','$imagefront','$imagemiddle','$imageback','$schoolcollage','$course','$class','$city','$code','$part','$category','$posterId','$publishingdate','$postingdate')";

希望这会对你有所帮助。