错误:函数Campaign :: camp_detls()的参数太少,0恰好传递了1个预期值

时间:2018-10-26 06:38:20

标签: php mysql codeigniter runtime-error codeigniter-3

我有一个表名 tbl_campaign_detail ,其中将 blogger_ID Campaign_id 添加为外键,其中有些其他领域。

我想从该表中删除记录。.当我执行删除操作时,它删除了记录但也给出了错误信息,

错误:

  

类型:ArgumentCountError

     

消息:函数Campaign :: camp_detls()的参数太少,第532行的D:\ XAMPP \ htdocs \ bms \ system \ core \ CodeIgniter.php中传递了0,并且恰好是1

     

文件名:D:\ XAMPP \ htdocs \ bms \ application \ controllers \ Campaign.php

     

行号:35

它工作正常,但也会显示此错误...

这是我的模特:

public function camp_detl_delete($did){

    $this->db->where('detail_id', $did);
    $this->db->delete('tbl_campaign_detail');
    if($this->db->affected_rows() > 0){
        return true;
    }else{
        return false;
    }
}

控制器:

public function camp_detl_delete($id){
    $result = $this->cm->camp_detl_delete($id);
    if($result){
        $this->session->set_flashdata('success_msg', 'Record deleted successfully');
    }else{
        $this->session->set_flashdata('error_msg', 'Faill to delete record');
    }
    redirect(base_url('campaign/camp_detls/')); //this should be directed to particular id of camp_detls
}

然后查看:

$did = $cmp->detail_id;
<a href="<?php echo base_url('campaign/camp_detl_delete/' .$did); ?>" onclick="return confirm('Do you want to delete this record?');">
                    <span class="glyphicon glyphicon-trash"></span>
                </a>

但在第35行中显示错误的地方是:

function camp_detls($id){
    $data['camps'] = $this->cm->camp_detailByID($id);
    $data['campaign'] = $this->cm->getCampaignsById($id);
    $data['blogger'] = $this->cm->getAllBloggers();
    $data['cat'] = $this->cm->getAllCategory();
    $this->load->view('layout/header');
    $this->load->view('campaign/campaign_detail', $data);
    $this->load->view('layout/footer');
}

请帮助,我该如何消除该错误? 我只想简单地删除它。

1 个答案:

答案 0 :(得分:0)

  

消息:函数Campaign :: camp_detls()的参数太少,0   通过(...)

此错误对您来说意味着您定义的函数(camp_detls())并要求$id,因为没有传递任何参数。

我想问题出在那行

redirect(base_url('campaign/camp_detls/')); //this should be directed to particular id of camp_detls

如暗示的建议,但请看。在这里您想重定向到特定的camp_detls,但不提供$id