我想显示用户插入的数据,以保存到数据库中的2个表中。但是这段代码对我不起作用。
$query = "INSERT INTO partnumber (Partnumber, Description, Min, Max) VALUES
('" . $_POST ["part"] . "', '" . $_POST["description"] . "', '" . $_POST["min"] . "', '" . ($_POST["max"]) . "')INSERT INTO forecast (Partnumber, Min, Max) VALUES
('". $_POST ["part"] . "', '" . $_POST["min"] . "','" . ($_POST["max"]) . "')";
$result = $db_handle->insertQuery($query);
if(!empty($result)) {
$error_message = "";
$success_message = "Saved successfully!";
unset($_POST);
} else {
$error_message = "Problem in saving. Try Again!";
}
$sql = "INSERT INTO forecast (Partnumber, Min, Max) VALUES
('". $_POST ["part"] . "', '" . $_POST["min"] . "','" . ($_POST["max"]) . "')";
$result = $db_handle->insertQuery($sql);
if(!empty($result)) {
$error_message = "";
$success_message = "Saved successfully!";
} else {
$error_message = "Problem in saving. Try again!";
}
错误是
无效查询
有人可以帮忙吗?
答案 0 :(得分:-1)
Your first two queries are separated by anything and it is not understood by SQL. You can use multi queries. Here is an example: bool mysqli_multi_query ( mysqli $link , string $query )
. You can read more about it here.