当我使用此脚本时,它得到:在此服务器上找不到请求的URL /StockManager/Product_Submit.php。
此外,尝试使用ErrorDocument处理请求时遇到404 Not Found错误。
并且它不会在MYsql数据库中输入任何内容。
这是我的剧本:
<?php
include 'Connect.php';
$ProName=htmlspecialchars($_POST["ProName"]);
$ProBuyprice=htmlspecialchars($_POST["ProBuyprice"]);
$ProWooPrice=htmlspecialchars($_POST["ProductWooPrice"]);
$WooId=htmlspecialchars($_POST["WooId"]);
$ProEbayPrice=htmlspecialchars($_POST["ProductEbayPrice"]);
$EbayId=htmlspecialchars($_POST["EbayId"]);
$ProQun=htmlspecialchars($_POST["ProQun"]);
$id=htmlspecialchars($_POST["userid"]);
$sql = ("INSERT INTO SoftwProducts(userid, Name, Qun, WooId, EbayId, BuyPrice, WooSelling, ebaySelling)
VALUES ($id,$ProName,$ProQun, $WooId, $EbayId, $ProBuyprice, $ProWooPrice, $ProEbayPrice)");
if (!mysqli_query($conn,$sql))
{
die('Error: ' . mysqli_error($conn));
}
echo "Success!";
?>
当我删除if语句时,只需执行:
mysqli_query($conn,$sql)
我没有收到404错误。 我究竟做错了什么。 提前谢谢!
答案 0 :(得分:1)
404错误找不到错误,由HTTP提供。这意味着该页面(在您的帖子中提到为tx()
不存在。
在我看来,您可能在/StockManager/Product_Submit.php
中使用了错误的action
属性(检查较低/较高的情况),或者您在脚本中的某处使用了错误的重定向。
答案 1 :(得分:0)
$sql = ("INSERT INTO SoftwProducts(userid, Name, Qun, WooId, EbayId, BuyPrice, WooSelling, ebaySelling)
VALUES ($id,$ProName,$ProQun, $WooId, $EbayId, $ProBuyprice, $ProWooPrice, $ProEbayPrice)");
if (!mysqli_query($conn,$sql))
{
die('Error: ' . mysqli_error($conn));
}
echo "Success!";
为:
$sql = "INSERT INTO SoftwProducts(userid, Name, Qun, WooId, EbayId, BuyPrice, WooSelling, ebaySelling)
VALUES ($id,'$ProName',$ProQun, $WooId, $EbayId, $EbayId, $ProWooPrice, $ProEbayPrice)";
if ($conn->query($sql) === TRUE) {
echo "New record created successfully";
} else {
echo "Error: " . $sql . "<br>" . $conn->error;
}
$conn->close();
无论如何,谢谢你的帮助: - )