gpt4 book ai didi

php - 更新 MySQL 后,为空 'float' 字段添加 0(零)而不是 null

转载 作者:行者123 更新时间:2023-11-29 10:16:04 25 4
gpt4 key购买 nike

在我的数据库中,我将默认值保留为空,并允许数据字段为空值,它在最新版本的 MySQL 上工作正常,但在最新版本的 MySQL 上,它将所有浮点值更新为 0并且不为 NULL。

这是表格示例

<tr>
<td>Birth Weight</td>
<td><input type="text" name="birthweight" placeholder=" Enter Birth Weight"> Kg</td>
</tr>
<tr>
<td>Date of Birth</td>
<td><input type="date" name="DateOfBirth" name="DateOfBirth" class="Select"></td>
</tr>
<tr>
<td>Sex</td>
<td><select name="sex" class="Select">
<option value ="--"> Select </option>
<option value="Male ">Male</option>
<option value="Female">Female</option>
</select>
</td>

php:

$db = mysqli_real_escape_string($link, $_REQUEST['DateOfBirth']);
$sx = mysqli_real_escape_string($link, $_REQUEST['sex']);
$birthwt = mysqli_real_escape_string($link, $_REQUEST['birthweight']);

$sql = "INSERT INTO tab1 (db, sx, birthwt)
VALUES ('$db', '$sx', '$birthwt')";

enter image description here

其他值更新为空值,但不是浮点值。我尝试搜索其他问题,但没有找到任何可以满足我的问题的内容。

最佳答案

我只是在查询下面添加了另一个查询,它将 0 值设置为 null。

关于php - 更新 MySQL 后,为空 'float' 字段添加 0(零)而不是 null,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/50095081/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com