PHP/MySQL 文本到数据库 table - 查询命中但文本为空

PHP/MySQL text to DB table - query hits but text empty

不太确定我哪里出错了。我需要对文本进行编码吗?当我作为测试回显时,它工作正常。数据库也正在被访问。但是当查询命中时,没有文本。

<?php
include($_SERVER['DOCUMENT_ROOT'].'/includes/dbh.php');
$newNote = mysqli_real_escape_string($conn, $_POST['note']);

if (empty($newNote)){
        header("Location: /admin/notes.php?error=empty");
        exit();
} else {
        $sql = "INSERT INTO notes (note) VALUES ('$NewNote')";
        $result = mysqli_query($conn, $sql);
        header("Location: /admin/notes.php?success");
    }
?>


<div class="section">
  <div class="container">
    <?php
     $url = "http://".$_SERVER['HTTP_HOST'].$_SERVER['REQUEST_URI'];
     if (strpos($url, 'error=empty') !== false) {
       echo "<div class='alert alert-danger'>Error: You must enter some text!</div>";
     }
     elseif (strpos($url, 'success') !== false) {
       echo "<div class='alert alert-success'>Note successfully submitted!</div>";
     }
    ?>
    <h3>Add Note</h3>
    <form action="/admin/includes/notes.inc.php" method="post">
      <div class="form-group">
        <textarea name="note" class="form-control m20" rows="5"></textarea>
        <button type="submit" name="submit" class="btn btn-default"><span class="glyphicon glyphicon-plus"></span> Submit</button>
      </div>
    </form>
  </div>
</div>

PHP 中的变量区分大小写。
您只需要将查询插入行中 $NewNote 变量的第一个 "N" 小写,它应该可以工作。