如何在 php 中将 tinyint 值更新为 1 而不是它变为 NULL
How do I update a tinyint value to 1 in php instead of it becoming 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>";
}
?>
我正在尝试将数据库布尔值 (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>";
}
?>