无法在 mysqli_stmt_bind_param 中找到要使用的 now() 的正确语法


Unable to find the proper syntax to use now() in mysqli_stmt_bind_param

我在Mysql数据库中有一列"received_on"定义为类型"datetime",我正在尝试在该字段中插入now()的值。

在PHP块中,我正在使用

mysqli_stmt_prepare($stmt, "INSERT INTO goods_receipts (product, qty, received_on) VALUES (?, ?, ?);
mysqli_stmt_bind_param($stmt, "sss", $_POST["product"], $_POST["qty"], now());

在 HTML 表单中,我正在使用

 input type="text" name="product"
 input type="text" name="qty"

我没有在 HTML 表单中为 received_on 元素定义任何输入。

当我尝试运行它时,我现在收到一个语法错误()。我显然搞砸了如何在没有任何用户输入的情况下使用 now() 的值更新 received_on 列的语法,但无法弄清楚在哪里。谁能帮忙?

NOW()是一个

MySQL函数,所以它只是查询的一部分,不需要准备:

mysqli_stmt_prepare($stmt, "INSERT INTO goods_receipts (product, qty, received_on) VALUES (?, ?, NOW())");
mysqli_stmt_bind_param($stmt, "ss", $_POST["product"], $_POST["qty"]);