【问题标题】:SQL update statement not updating on phpmyadmin recordSQL 更新语句未更新 phpmyadmin 记录
【发布时间】:2018-09-12 08:40:36
【问题描述】:

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

$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

已经尝试更新命令得到同样的问题

$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

【问题讨论】:

  • INSERT 没有 WHERE 子句。 (新行插入到表中。)使用 UPDATE 更新行的列。
  • 您要插入或更新什么?您为插入而不是更新编写的查询

标签: php sql phpmyadmin dreamweaver


【解决方案1】:

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

【讨论】:

  • 已经尝试更新命令得到同样的问题 $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:无法执行您的 SQL 语法有错误;检查与您的 MySQL 服务器版本相对应的手册,以在第 1 行的 '[Secret Life Of Walter Mitty],Certificate=[18],Director=[Ben Stiller],`Genre' 附近使用正确的语法
  • @Ollie,请将该评论复制到您的问题中! (注意缺少的单引号...比较 INSERT 和 UPDATE 尝试...)
猜你喜欢
  • 1970-01-01
  • 2015-06-26
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2021-05-29
相关资源
最近更新 更多