为什么MYSQLi不更新数据库记录但是给出成功消息

Jas*_*ine -1 php mysqli

我已经清理了我的代码,以便将以下内容作为我的表单.但是我无法从新的update.php发送数据和更新.该表单可以正常检索数据并显示它.但是在提交时我收到了ok更新消息但是数据库中的记录没有改变任何想法.的index.php

<?php
  include 'connectdb.php';
  // include 'query.php';

  $sql = "SELECT id, WeightorMeasure FROM weightsmeasures";
  $result = $conn->query($sql)       
  if ($result->num_rows > 0) {

    // output data of each row
    while($row = $result->fetch_assoc()) {
    echo "<form action=\"update.php\"method=\"post\">";
    echo "<input type=\"text\" name=\"id\" value = ".$row["id"].">";
    echo "<input type=\"text\" name=\"WeightorMeasure\" value = ".$row["WeightorMeasure"] .">";
    echo "<input type=\"submit\" value=\" Submit \" name=\"Update\">";
    }
        echo "</form>";
    } else {
        echo "0 results";
    }  
       $conn->close();
?>
Run Code Online (Sandbox Code Playgroud)

update.php

<?php
  include 'connectdb.php';
  $wm = $_POST['id'];
  $id = $_POST['WeightorMeasure'];
  $sql = "UPDATE weightsmeasures SET WeightorMeasure='$wm' WHERE id='$id'";

    if (mysqli_query($conn, $sql)) {
        echo "Record updated successfully";
    } else {
        echo "Error updating record: " . mysqli_error($conn);
    }

    $conn->close();
?>
Run Code Online (Sandbox Code Playgroud)

已更改为"下方",现在出现此错误.更新记录时出错:"字段列表"中的未知列'sdada'.所以看起来它试图使用表单值$ wm作为表中的列标题而不是输入值.

$wm = $_POST['WeightorMeasure'];
$id = $_POST['id'];


$sql = "UPDATE weightsmeasures SET WeightorMeasure=$wm WHERE id=$id";
Run Code Online (Sandbox Code Playgroud)

IsT*_*ipt 7

 $wm = $_POST['id'];
 $id = $_POST['WeightorMeasure'];      
Run Code Online (Sandbox Code Playgroud)

也许你有这些错误的方式?:d

 $wm = $_POST['WeightorMeasure'];
 $id = $_POST['id'];
Run Code Online (Sandbox Code Playgroud)

顺便说一下,你的查询对于MySQL注入是不可思议的,请考虑使用预处理语句