简体   繁体   中英

error: Too few arguments to function Campaign::camp_detls(), 0 passed exactly 1 expected

i have a table name tbl_campaign_detail in which blogger_ID and Campaign_id are added as a foreign key with some other fields..

i want to delete record from this table.. when i perform delete, it deleted the record but also give an error,

error:

Type: ArgumentCountError

Message: Too few arguments to function Campaign::camp_detls(), 0 passed in D:\\XAMPP\\htdocs\\bms\\system\\core\\CodeIgniter.php on line 532 and exactly 1 expected

Filename: D:\\XAMPP\\htdocs\\bms\\application\\controllers\\Campaign.php

Line Number: 35

it works perfectly but also shows this error...

Here is my model:

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;
    }
}

Controller:

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
}

And view:

$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>

but where it shows error mentioned in controller line 35 is:

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');
}

Kindly help, how can i remove this error ? i just want it delete simply.

Message: Too few arguments to function Campaign::camp_detls(), 0 passed (...)

This error means for you that to the function ( camp_detls() ) you defined and required $id as argument was nothing passed.

I suppose the problem is in the line:

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

as comment suggesting it, but look. Here you want to redirect to particular camp_detls but you do not provide $id .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM