gpt4 book ai didi

php - 已成功提交表单,但控制台中出现一个错误,例如发生数据库错误错误号 : 1048 - Codeigniter

转载 作者:行者123 更新时间:2023-11-29 15:33:21 25 4
gpt4 key购买 nike

当我成功提交表单并在表中插入所有数据时,并且在控制台中收到如下错误,代码中是否有任何问题?,我在错误中发现了不寻常的日期,日期显示为“1970-” 01-01'。但我选择了今天的日期,但错误地只显示了“1970-01-01”;

A Database Error Occurred
Error Number: 1048

Column 'purchase_shopId' cannot be null

INSERT INTO `stock_purchase_history` (`purchase_shopId`, `purchase_productID`, `purchase_quantity`, `purchase_costPrice`, `purchase_TotalRate`, `purchase_tax`, `purchase_taxEmp`, `purchase_sellingPrice`, `purchase_employeeSellingPrice`, `purchase_supplierName`, `purchase_invoice`, `purchase_PurchaseDate`) VALUES (NULL, NULL, NULL, NULL, 0, NULL, NULL, 0, 0, NULL, NULL, '1970-01-01')

Filename: C:/xampp/htdocs/stock/system/database/DB_driver.php

Line Number: 691

我的查询代码

public function insertPurchaseData()
{
$shopId = $this->input->post('shopId');
$productID = $this->input->post('productID');
$quantity = $this->input->post('quantity');
$costPrice = $this->input->post('costPrice');
$PurchaseTotalRate = $quantity*$costPrice;
$taxNormal = $this->input->post('taxNormal');
$taxEmp = $this->input->post('taxEmp');
$supplierName = $this->input->post('supplierName');
$invoice = $this->input->post('invoice');
$PurchaseDate = date('Y-m-d', strtotime($this->input->post('PurchaseDate')));
// normal Selling price
$sellingPrice=($costPrice*$taxNormal)/100+$costPrice ;

// emp selling price
$employeeSellingPrice=($costPrice*$taxEmp)/100+$costPrice;

$purchaseData =array(

'purchase_shopId' => $shopId,
'purchase_productID' => $productID,
'purchase_quantity' =>$quantity,
'purchase_costPrice' =>$costPrice,
'purchase_TotalRate' =>$PurchaseTotalRate,
'purchase_tax' =>$taxNormal,
'purchase_taxEmp' =>$taxEmp,
'purchase_sellingPrice' =>$sellingPrice,
'purchase_employeeSellingPrice'=>$employeeSellingPrice,
'purchase_supplierName' =>$supplierName,
'purchase_invoice' =>$invoice,
'purchase_PurchaseDate' =>$PurchaseDate

);
$this->db->insert('stock_purchase_history',$purchaseData);



}

参见下面的ajax代码

      if(result == '1234567')
{
$.ajax({
type: "POST",
url: "<?php echo site_url('Con_purchase/add_purchase_for_shop')?>",
dataType: "JSON",
data: {
shopId: shopId,
productID: productID,
quantity: quantity,
costPrice : costPrice ,
taxNormal : taxNormal ,
taxEmp : taxEmp ,
supplierName : supplierName,
invoice : invoice ,
PurchaseDate : PurchaseDate
},
success: function(data)
{ if (data == '1') {
var btn = $(this).closest("tr")
var name = inputData.find("button").prop('disabled', false).css(
"background-color", "green");
} else {
var btn = $(this).closest("tr")
var name = inputData.find("button").prop('disabled', true).css(
"background-color", "#2d7bf4");

}
}

});
return false;
}

我的数据库 enter image description here

最佳答案

您必须将列结构更改为 null 'purchase_shopId',因为您已选中 null 复选框。

关于php - 已成功提交表单,但控制台中出现一个错误,例如发生数据库错误错误号 : 1048 - Codeigniter,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/58511467/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com