2016-12-23 30 views
-3

我不認爲應該有任何錯誤請檢查並快速回復。我認爲它的一切正常,但它給了一些簡單的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 

的數據我進入不包含任何

請幫助和感謝提前

+6

至少你缺少一個右括號 –

+0

也不要使用這種方式做SQL查詢。使用參數。它可以爲你節省很多未來的問題 –

+0

@SamiKuhmonen:你應該考慮在上面的評論中提出建議,因爲它會回答實際的帖子,以便將其標記爲如此。 – nyedidikeke

回答

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

希望這將錯誤幫助你。

相關問題