-2

此语句中的语法错误在哪里?我不明白,在这种情况下我可以使用“?绑定参数方法”吗?我使用 PDO

$stmt = $dbh->prepare("INSERT INTO epinfo WHERE TVShowTitle=? (Season, Episode, SDLink, HDLink, DlSDLink, DlHDLink) VALUES (?, ?, ?, ?, ?, ?)");
$stmt->bindParam(1, $_POST[tvshow]);
$stmt->bindParam(2, $_POST[season]);
$stmt->bindParam(3, $_POST[episode]);
$stmt->bindParam(4, $_POST[sdlink]);
$stmt->bindParam(5, $_POST[hdlink]);
$stmt->bindParam(6, $_POST[dlsdlink]);
$stmt->bindParam(7, $_POST[dlhdlink]);
$stmt->execute();

Error message:

SQLSTATE[42000]: Syntax error or access violation: 1064 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 TVShowTitle='Breaking Bad' (Season, Episode, SDLink, HDLink, DlSDLink, DlH' at line 1
4

3 回答 3

1

标准INSERT语法没有WHERE子句。我想你想要UPDATE你现有的记录。

UPDATE epinfo 
SET Season = ?, 
    Episode = ?, 
    SDLink = ?, 
    HDLink = ?, 
    DlSDLink = ?, 
    DlHDLink = ?
WHERE TVShowTitle=?
于 2013-09-22T17:33:40.190 回答
1
INSERT INTO epinfo (TVShowTitle, Season, Episode, SDLink, HDLink, DlSDLink, DlHDLink) VALUES (?, ?, ?, ?, ?, ?, ?)"
于 2013-09-22T17:35:17.320 回答
1

您需要删除 where 子句。

从这里

  INSERT INTO epinfo WHERE

试试这样: -

 INSERT INTO epinfo(Season, Episode, SDLink, HDLink, DlSDLink, DlHDLink) 
 VALUES (?, ?, ?, ?, ?, ?)

从您的评论中:

如果要更新值,请像这样使用它:-

update epinfo
set column = "value"
where TVShowTitle=?
于 2013-09-22T17:35:36.510 回答