更新MySQL后,为空“浮动”字段添加0(零)而不是空

时间:2018-04-30 06:31:17

标签: php mysql

在我的数据库中,我将默认值保持为null并且为我的数据字段保留了空值,并且它在最后一个版本的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

其他值更新为null但不是浮点值。我试着搜索其他问题但没有找到适合我的问题的任何东西。

1 个答案:

答案 0 :(得分:1)

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