错误:campaign::camp\u detls()函数的参数太少,0正好传递了1

kkbh8khc  于 2021-06-18  发布在  Mysql
关注(0)|答案(1)|浏览(359)

我有一个表名tbl\u campaign\u detail,其中blogger\u id和campaign\u id作为外键与其他字段一起添加。。
我想从此表中删除记录。。当我执行删除时,它删除了记录,但也给出了一个错误,
错误:
类型:argumentcounterror
消息:campaign::camp\u 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');
}

请帮忙,我怎样才能消除这个错误?我只想把它删掉。

l7mqbcuq

l7mqbcuq1#

消息:函数campaign::camp\u detls()的参数太少,传递了0(…)
这个错误对你来说意味着函数( camp_detls() )您定义并要求 $id 因为争论没有通过。
我想问题出在:

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

就像你说的那样,但是看看。在这里你想重定向到特定的 camp_detls 但你不提供 $id .

相关问题