我的问题是,只要我有使用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");
答案 0 :(得分: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'
));
}
答案 1 :(得分:0)
从更新集中删除gname
字段。
$Statement = $conn->prepare("UPDATE $boss SET `Bossname` =:boss, `Screenshot` =:screen, `Link` =:link, `KillTime` =:defeattime, `KillYN` =:kill WHERE `GuildName`=:gname");
如果您认为gname
在更新SET
中很重要,您可以尝试其他不同的名称或尝试更改其他字段的位置,例如id