当用户提交数据时,我将收到此错误
致命错误:未捕获错误:在C:\ xampp \ htdocs \ smac \ catalog \ controller \ payment \ payment.php中调用null上的成员函数insert():45
这是我的tpl文件
public function index()
{
$this->load->model('payment/payment');
$this->data['action'] = $this->url->link('payment/payment');
if (($this->request->server['REQUEST_METHOD'] == 'POST')) {
$id= $this->model_payment_payment->insert($this->request->post);
}
$this->response->setOutput($this->load->view('payment/payment', $data));
}
控制器文件:
<?php
class ModelPaymentPayment extends Model
{
public function insert($data)
{
$this->db->query("INSERT INTO " . DB_PREFIX . "naveen SET
name = '" . $this->db->escape($data['name']) . "',
email = '" . $this->db->escape($data['email']) . "'");
$address_id = $this->db->getLastId();
return $address_id;
}
}
这是我的模型文件
{
search:{
keyword:"_"
},
dateCreated:"",
device:[{
deviceID:"_"
}],
}
如果我有任何错误,请提及它。
答案 0 :(得分:0)
我认为问题出在您的控制器文件中。你应该使用
$this->data['action'] = $this->url->link('payment/payment');
$this->response->setOutput($this->load->view('payment/payment', $this->data))
OR
$data['action'] = $this->url->link('payment/payment');
$this->response->setOutput($this->load->view('payment/payment', $data))