Php $\框架codeigniter的POST为空
我对一个小脚本my$\u POST return null有问题,但我不明白为什么,请帮助我 我的错误消息:Php $\框架codeigniter的POST为空,php,mysql,database,codeigniter,post,Php,Mysql,Database,Codeigniter,Post,我对一个小脚本my$\u POST return null有问题,但我不明白为什么,请帮助我 我的错误消息: Error Number: 1048 Column 'credit_id' cannot be null INSERT INTO `trader_order` (`trader_id`, `credit_id`, `credit`, `amount`, `payment_status`, `added_date`) VALUES ('40', NULL, NULL, NULL, 'No
Error Number: 1048
Column 'credit_id' cannot be null
INSERT INTO `trader_order` (`trader_id`, `credit_id`, `credit`, `amount`, `payment_status`, `added_date`) VALUES ('40', NULL, NULL, NULL, 'No', '2015-04-08 22:59:10')
Filename: /homepages/0/d433601931/htdocs/Wisementrade/new_version/models/trader_model.php
Line Number: 190
PHP控制器:
public function trader\u buy\u commission(){
$trader_id=$this->session->userdata('customer_id');
$cred_id=$_POST[“cred_id”];
$price=$this->trader->getPrice($cred_id);
$value=$this->trader->verify_credit_amount($u SESSION['credit_SESSION'],$price->price);
$payment\u status=“否”;
$\会话['credit\u trader\u amount']=$price->price;
$amount=$price->price;
$credit=$price->credit;
$orderid=$this->trader->insert_credit_order_详情($trader_id、$cred_id、$credit、$amount、$payment_status);
}
PHP模型:
HTML:
对不起,我对Codeigniter还是个新手,还是个学生,所以如果这个答案不太好,就忽略它吧
您的问题是否与您将$\u POST['cred\u id']设置为$cred\u id有关
$cred_id = $_POST["cred_id"];
然后在以后使用$credit\u id
$this->trader->insert_credit_order_detail($trader_id, $credit_id,$credit,$amount,$payment_status);
因为我已经做了很多动作,但是我已经编辑了我的帖子。你也在使用$credit\u idprice=$this->trader->getPrice($credit\u id)代码>此处尝试将其更改为$cred_id。您表单的HTML代码是什么?我不明白您想说什么。您问题的HTML代码部分不完整。您应该向我们显示提交数据的HTML的标记
。请尝试在控制器内检查是否(!empty($cred_id))
,如果它进入控制器内,您必须在模型内以相同的条件检查它。您确定在提交之前从选择框中选择了任何选项吗?
$this->trader->insert_credit_order_detail($trader_id, $credit_id,$credit,$amount,$payment_status);