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 HFSS 中的 H 场图与 MATLAB 中绘制的 B1 场 部分对应不上
  • ¥15 如何在scanpy上做差异基因和通路富集?
  • ¥20 关于#硬件工程#的问题,请各位专家解答!
  • ¥15 关于#matlab#的问题:期望的系统闭环传递函数为G(s)=wn^2/s^2+2¢wn+wn^2阻尼系数¢=0.707,使系统具有较小的超调量
  • ¥15 FLUENT如何实现在堆积颗粒的上表面加载高斯热源
  • ¥30 截图中的mathematics程序转换成matlab
  • ¥15 动力学代码报错,维度不匹配
  • ¥15 Power query添加列问题
  • ¥50 Kubernetes&Fission&Eleasticsearch
  • ¥15 報錯:Person is not mapped,如何解決?