我如何将微调值更新为PHP中的1,而不是将其变为null



我正在尝试将数据库布尔值(tinyint)值更新为1,但是,它正在更新为null,所有其他值都正确更改。

当我离开时,我遇到的错误是:

绑定失败:0执行失败:2031在准备好的语句中没有为参数提供的数据

如果我更改$ dealt_out = 1;在变量之前,在准备好的语句之前,所有值都正确更改了,除了布尔值,最终以null为单位。

<?php
if(!($stmt = $mysqli->prepare("UPDATE card SET player_Holding = ?, dealt_Out = 1 WHERE id_Card = ?"))){ 
echo "Prepare failed: "  . $stmt->errno . " " . $stmt->error;
}
if(!($stmt->bind_param("iii",$_POST['player_Holding'],$_POST['dealt_Out'],$_POST['id_Card']))){
echo "Bind failed: "  . $stmt->errno . " " . $stmt->error;
}
if(!$stmt->execute()){
echo "Execute failed: "  . $stmt->errno . " " . $stmt->error;
}     else {
echo "Edit " . $stmt->affected_rows . " row to Card Holder. <br/><br/><strong>Returning to 'Make a Move'</strong>";
}
?>

检查很好。它应该是 delt_out =?不是 delt_out = 1 如果没有,请在bind_param中取出 $ _ post ['delt_out'],,然后删除一个 i

我已经修改了您的代码。希望它能解决您的问题

<?php
$dealtout=1;
if(!($stmt = $mysqli->prepare("UPDATE card SET player_Holding = ?, dealt_Out = ? WHERE id_Card = ?"))){ 
echo "Prepare failed: "  . $stmt->errno . " " . $stmt->error;
}
if(!($stmt->bind_param("iii",$_POST['player_Holding'],$dealtout,$_POST['id_Card']))){
echo "Bind failed: "  . $stmt->errno . " " . $stmt->error;
}
if(!$stmt->execute()){
echo "Execute failed: "  . $stmt->errno . " " . $stmt->error;
}     else {
echo "Edit " . $stmt->affected_rows . " row to Card Holder. <br/><br/><strong>Returning to 'Make a Move'</strong>";
}
?>

相关内容

  • 没有找到相关文章

最新更新