(PDO) UPDATE 不更新 WHERE 变量

(PDO) UPDATE doesn't update with WHERE variable


我的问题是,一旦我有了 GuildName 的 WHERE,它就不起作用了。它根本不更新任何东西。
一旦我有了 id=1(有 100 个公会,所以设置 id=1 不是一个选项)它就起作用了。

$form           = $_POST;
$boss           = $form['bossname'];
$gname          = $form['guildname'];
$screen         = $form['screenshot'];
$log            = $form['logs'];
$defeat         = $form['defeat'];

if(isset($_POST['edit-guild'])){

    $Statement = $conn->prepare("UPDATE $boss SET `Bossname` =:boss, `GuildName` =:gname, `Screenshot` =:screen, `Link` =:link, `KillTime` =:defeattime, `KillYN` =:kill WHERE `GuildName`=:gname");
    // EXECUTING ARRAY FOR ^GUILD INFORMATION
    $Statement->execute(array(
        "boss"          => $boss,
        "gname"         => $gname,
        "screen"        => $screen,
        "link"          => $log,
        "defeattime"    => $defeat,
        "kill"          => 'Yes'
        ));
}

只要我有 WHERE id=1 它就可以工作。

 $Statement = $conn->prepare("UPDATE $boss SET `Bossname` =:boss, `GuildName` =:gname, `Screenshot` =:screen, `Link` =:link, `KillTime` =:defeattime, `KillYN` =:kill WHERE id=1");

如前所述,您不能重复使用相同的参数。尝试给它一个不同的名称:

if(isset($_POST['edit-guild'])){

    $Statement = $conn->prepare("UPDATE $boss SET `Bossname` =:boss, `GuildName` =:gname, `Screenshot` =:screen, `Link` =:link, `KillTime` =:defeattime, `KillYN` =:kill WHERE `GuildName`=:gname2");
    // EXECUTING ARRAY FOR ^GUILD INFORMATION
    $Statement->execute(array(
        "boss"          => $boss,
        "gname"         => $gname,
        "gname2"         => $gname,
        "screen"        => $screen,
        "link"          => $log,
        "defeattime"    => $defeat,
        "kill"          => 'Yes'
        ));
}

从更新集中删除 gname 字段。

$Statement = $conn->prepare("UPDATE $boss SET `Bossname` =:boss, `Screenshot` =:screen, `Link` =:link, `KillTime` =:defeattime, `KillYN` =:kill WHERE `GuildName`=:gname");

如果您认为 gname 在更新 SET 中很重要,您可以尝试另一个不同的名称或尝试更改 where 条件另一个字段,例如 id