SQL更新语句未在phpmyadmin记录上更新

时间:2018-09-12 08:40:37

标签: php sql phpmyadmin dreamweaver

您好现在已经从事了一段时间,但似乎无法弄清为什么它不会更新。 我已经写了该语句,但是当它运行时它根本不会更新记录,但是我看不出有什么问题。

$query = ("INSERT INTO tbldvd(Title, Certificate, Director, Genre, Synopsis, RentalAmount, BeingRented) VALUES('$Title','$Certification','$Director','$Genre','$Synopsis','$Price','$Rented') WHERE DVDID= ".$ID.""); 

是我的查询,运行时出现错误

ERROR 404: Could not able to execute INSERT INTO tbldvd(Title, Certificate, Director, Genre, Synopsis, RentalAmount, BeingRented) VALUES ('Secret Life Of Walter Mitty','18','Ben Stiller','Family','Day Dreamer','5.00','No') WHERE DVDID= 3 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 'WHERE DVDID= 3' at line 1

已经尝试使用update命令来获得相同的问题

$query = mysqli_query($con, "UPDATE tbldvd SET Title=[$Title],Certificate=[$Certification],Director=[$Director],Genre=[$Genre],Synopsis=[$Synopsis],RentalAmount=[$Price],BeingRented=[$Rented] WHERE DVDID = $ID"); 

我哪里出错了

ERROR 404: Could not able to execute 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 '[Secret Life Of Walter Mitty],Certificate=[18],Director=[Ben Stiller],`Genre' at line 1

1 个答案:

答案 0 :(得分:-1)

您必须使用UPDATE语法。参见https://www.w3schools.com/sql/sql_update.asp