dsdqpdjpq16640651 2018-10-26 06:38
浏览 105
已采纳

错误:运行Campaign :: camp_detls()的参数太少,0正好通过了1个预期

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.

  • 写回答

1条回答 默认 最新

  • doulan8054 2018-10-26 06:44
    关注

    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.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 shape_predictor_68_face_landmarks.dat
  • ¥15 slam rangenet++配置
  • ¥15 有没有研究水声通信方面的帮我改俩matlab代码
  • ¥15 对于相关问题的求解与代码
  • ¥15 ubuntu子系统密码忘记
  • ¥15 信号傅里叶变换在matlab上遇到的小问题请求帮助
  • ¥15 保护模式-系统加载-段寄存器
  • ¥15 电脑桌面设定一个区域禁止鼠标操作
  • ¥15 求NPF226060磁芯的详细资料
  • ¥15 使用R语言marginaleffects包进行边际效应图绘制