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 flink cdc无法实时同步mysql数据
  • ¥100 有人会搭建GPT-J-6B框架吗?有偿
  • ¥15 求差集那个函数有问题,有无佬可以解决
  • ¥15 【提问】基于Invest的水源涵养
  • ¥20 微信网友居然可以通过vx号找到我绑的手机号
  • ¥15 寻一个支付宝扫码远程授权登录的软件助手app
  • ¥15 解riccati方程组
  • ¥15 使用rabbitMQ 消息队列作为url源进行多线程爬取时,总有几个url没有处理的问题。
  • ¥15 Ubuntu在安装序列比对软件STAR时出现报错如何解决
  • ¥50 树莓派安卓APK系统签名