我有这些变量:
$cliente = mysqli_real_escape_string($conn, htmlentities($_GET["cliente"]));
$metatickt = mysqli_real_escape_string($conn, htmlentities($_GET["metatickt"]));
$metaext = mysqli_real_escape_string($conn, htmlentities($_GET["metaext"]));
$metaenc = mysqli_real_escape_string($conn, htmlentities($_GET["metaenc"]));
$uf = mysqli_real_escape_string($conn, htmlentities($_GET["estado"]));
我正在尝试执行此查询:
$queryInst = "INSERT meta_control (mes,cliente,meta_exit,meta_tickt,meta_enc,uf)"
. " VALUES (MONTH(NOW()),'" . $cliente . "','" . $metaext . "','" . $metatickt . "','" . $metaenc . "','" . $uf . "')";
mysqli_query($conn, $queryInst);
但是当我检查我的数据库时,唯一不为NULL的列是mes
。可能是什么原因造成的?
答案 0 :(得分:1)
您应该使用正确的查询。 INSERT INTO
$queryInst = "INSERT INTO meta_control (mes,cliente,meta_exit,meta_tickt,meta_enc,uf)"
. " VALUES (MONTH(NOW()),'" . $cliente . "','" . $metaext . "','" . $metatickt . "','" . $metaenc . "','" . $uf . "')";
mysqli_query($conn, $queryInst);
答案 1 :(得分:0)
您可能遇到SQL错误。
您应该使用mysqli_error($conn)
- http://php.net/manual/en/mysqli.error.php检查此类错误。在这种情况下,您可能会因SQL查询中缺少INTO
关键字而导致错误,该关键字应为INSERT INTO ....
http://dev.mysql.com/doc/refman/5.7/en/insert.html