遇到未捕获的异常类型:ArgumentCountError消息:函数Cats100 :: sale()的参数太少,传递了0

没有:

单击视图上的销售按钮后出现错误

错误 :

遇到未捕获的异常

类型:ArgumentCountError

消息:函数Cats100 :: sale()的参数太少,第532行的C:\ xampp \ htdocs \ catshop100 \ system \ core \ CodeIgniter.php中传递了0

文件名:C:\ xampp \ htdocs \ catshop100 \ application \ controllers \ Cats100.php

行号:61

回溯:

文件:C:\ xampp \ htdocs \ catshop100 \ index.php

线:315

函数:require_once

控制器:

<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');

class Cats100 extends CI_Controller {

  public function __construct(){
    parent::__construct();
    $this->load->library('session');
    $this->load->helper('url');
    $this->load->model('CatsModel100');
    $this->load->model('CateModel100');
  }

  public function index(){
    $data['cats100'] = $this->CatsModel100->view();
    $this->load->view('kucing/index_cats_100', $data);
  }

  public function tambah(){
    if($this->input->post('submit')){
      if($this->CatsModel100->validation("save")){ 
        $this->CatsModel100->save();
        if($this->db->affected_rows() > 0){
          $this->session->set_flashdata('msg','Cat Successfuly Added');
        }else{
            $this->session->set_flashdata('msg','Cat Add Failed');
        }
        redirect('cats100');
      }
    }
    $data['category']=$this->CateModel100->view();
    $this->load->view('kucing/form_tambah_cats_100', $data);
  }

  public function ubah($id){
    if($this->input->post('submit')){
      if($this->CatsModel100->validation("update")){ 
        $this->CatsModel100->edit($id);
        if($this->db->affected_rows() > 0){
          $this->session->set_flashdata('msg','Cat Successfuly Edited');
        }else{
            $this->session->set_flashdata('msg','Cat Edit Failed');
        }
        redirect('cats100');
      }
    }
    $data['category']=$this->CateModel100->view();
    $data['cats100'] = $this->CatsModel100->view_by($id);
    $this->load->view('kucing/form_ubah_cats_100', $data);
  }

  public function hapus($id){
    $this->CatsModel100->delete($id);
    if($this->db->affected_rows() > 0){
      $this->session->set_flashdata('msg','Cat Successfuly Deleted');
    }else{
        $this->session->set_flashdata('msg','Cat Delete Failed');
    }
    redirect('cats100');
  }

  public function sale($id){
    if($this->input->post('submit')){
            $this->CatModel100->sale($id);
            if($this->db->affected_rows() > 0){
                $this->session->set_flashdata('msg','<p  style="color:black">Cat Succesfully Sold!</p>');
            }else{
                $this->session->set_flashdata('msg','<p  style="color:red">Cat Sale Failed!</p>');
            }
            redirect('cats100');
        }
    $data['cats100'] = $this->CatsModel100->view_by($id);
    $this->load->view('kucing/cat_sale_100', $data);
  }
}

型号:

<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');

class CatsModel100 extends CI_Model {

  public function view(){
    return $this->db->get('cats100')->result();
  }

  public function view_by($id){
    $this->db->where('id_100', $id);
    return $this->db->get('cats100')->row();
  }

  public function validation($mode){
    $this->load->library('form_validation'); 

    if($mode == "save")
        $this->form_validation->set_rules('input_id', 'ID', 'required|numeric|max_length[10]');
        $this->form_validation->set_rules('input_name', 'Nama', 'required');
        $this->form_validation->set_rules('input_type', 'Type', 'required');
        $this->form_validation->set_rules('input_gender', 'Gender', 'required');
        $this->form_validation->set_rules('input_age', 'Age', 'required');
        $this->form_validation->set_rules('input_price', 'Price', 'required');

    if($this->form_validation->run()) 
      return TRUE; 
    else 
      return FALSE; 
  }

  public function save(){
    $data = array(
      "id_100" => $this->input->post('input_id'),
      "name_100" => $this->input->post('input_name'),
      "type_100" => $this->input->post('input_type'),
      "gender_100" => $this->input->post('input_gender'),
      "age_100" => $this->input->post('input_age'),
      "price_100" => $this->input->post('input_price')
    );
    $this->db->insert('cats100', $data); 
  }

  public function edit($id){
    $data = array(
        "name_100" => $this->input->post('input_name'),
        "type_100" => $this->input->post('input_type'),
        "gender_100" => $this->input->post('input_gender'),
        "age_100" => $this->input->post('input_age'),
        "price_100" => $this->input->post('input_price')
    );

    $this->db->where('id_100', $id);
    $this->db->update('cats100', $data); 
  }

  public function delete($id){
    $this->db->where('id_100', $id);
    $this->db->delete('cats100');
  }

  public function sale($id){
    $data = array(
      "customer_name_100" => $this->input->post('customer_name_100'),
      "customer_address_100" => $this->input->post('customer_address_100'),
      "customer_phone_100" => $this->input->post('customer_phone_100'),
      "cat_id_100" => $id
    );
    $this->db->insert('catsales100', $data); 
    $this->db->set('sold_100', '1');
    $this->db->where('id_100', $id);
    $this->db->update('cats100', $sold); 
  }
}

查看:

<html>
  <head>
    <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.4.1/css/bootstrap.min.css">
    <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.4.1/jquery.min.js"></script>
    <script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.16.0/umd/popper.min.js"></script>
    <script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.4.1/js/bootstrap.min.js"></script>
    <title>Form Cat Sale - CATSHOP100</title>
  </head>
    <body style="background-color:aquamarine;">
    <nav class="navbar navbar-expand-md bg-dark navbar-dark fixed-top">
        <a href="<?=base_url();?>" class="navbar-brand">Catshop100</a>
          <button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#collapsibleNavbar">
              <span class="navbar-toggler-icon"></span>
          </button>
          <div class="collapse navbar-collapse" id="collapsibleNavbar">
              <ul class="navbar-nav">
                  <li class="nav-item">
                      <a href="<?=site_url('cats100')?>" class="nav-link">Manage Cats</a>
                  </li>
                  <li class="nav-item">
                    <a href="<?=site_url('cat100')?>" class="nav-link">Manage Categories</a>
                  </li>
                  <li class="nav-item">
                    <a href="<?=site_url('user100')?>" class="nav-link">Manage Users</a>
                  </li>
              </ul>
          </div>
    </nav>
    <br><br><br><br>
    <?php echo form_open("cats100/sale"); ?>
    <div class="container bg-dark text-white" style="width:50%;">
        <h2>Form Cat Sales</h2>
        <div class="form-group">
            <label for="cat id">Cat ID</label>
            : <?php echo set_value('input_id', $cats100->id_100); ?>
        </div>
        <div class="form-group">
            <label for="cat name">Cat Name</label>
            : <?php echo set_value('input_name', $cats100->name_100); ?>
        </div>
        <div class="form-group">
            <label for="cat type">Cat Type</label>
            : <?php echo set_value('input_price', $cats100->type_100); ?>
        </div>
        <div class="form-group">
            <label for="cat price">Cat Price</label>
            : $.<?php echo set_value('input_price', $cats100->price_100); ?>
        </div>
        <div class="form-group">
            <label for="customer name">Customer Name</label>
            <input type="text" name="customer_name_100" class="form-control">
        </div>
        <div class="form-group">
            <label for="customer address">Customer Address</label>
            <textarea name="customer_address_100" id="" class="form-control"></textarea>
        </div>
        <div class="form-group">
            <label for="customer phone">Customer Phone</label>
            <input type="text" name="customer_phone_100" class="form-control">
        </div>
        <div class="form-group">
            <input type="submit" name="submit" value="Sale" class="btn btn-success">
            <a href="<?=site_url('cats100')?>"><input type="button" value="Batal" class="btn btn-danger"></a>
        </div>
    </div>
    </body>
<html>

请帮我解决这个问题

Akshit Arora:

<?php echo form_open("cats100/sale"); ?>视图文件中的代码中,您需要根据控制器中的函数声明传递应充当$ id的变量public function sale($id){...

本文收集自互联网,转载请注明来源。

如有侵权,请联系 [email protected] 删除。

编辑于
0

我来说两句

0 条评论
登录 后参与评论

相关文章

如何解决致命错误:Uncaught ArgumentCountError:函数Login :: login()的参数太少,传递了0?

函数的参数太少,传递了0个参数,在Laravel中恰好期望1个参数

Symfony DI:未捕获的ArgumentCountError:函数App :: __ construct()的参数太少,第28行的index.php中传递了0,而预期的恰好是1

“类型错误:函数App \ Http \ Controllers \ UserController :: attendance()的参数太少,传递了0个且正好是1个”

函数App \ Http \ Controllers \ CartController :: destroy()的参数太少,传递了0个且恰好期望有1个

函数App \ Http \ Controllers \ CategoryController :: destroy()的参数太少,传递了0个且恰好期望1个

传递给函数App \ Http \ Controllers的参数太少,传递了1个,恰好期望2个

我遇到以下错误:“类型错误:函数AlbumController :: postEdit()的参数太少,传递了1个且恰好期望2个”

致命错误:未捕获的 ArgumentCountError:函数 Admincategory::deletecategory() 的参数太少,

WooCommerce:致命错误:未捕获的ArgumentCountError:函数的参数太少

未捕获的 ArgumentCountError:函数 phpfmg_hsc() 的参数太少,1

未捕获的ArgumentCountError:函数wpdb :: prepare()的参数太少

如何修复未捕获的 ArgumentCountError:函数 Update::index() 的参数太少,

函数的可为空类型参数上未捕获的ArgumentCountError

Laravel ::类型错误:函数App \ Product :: getTax()的参数太少,已传递0

函数调用报告尽管传递了有效参数,但仍给出了 0 个参数

Laravel:传递给函数0的参数太少,预期恰好有1个”

传递给Laravel中的函数的参数太少

Powershell函数传递了太多参数

函数Db :: __ construct()的参数太少,传入的0

致命错误:未捕获的ArgumentCountError:函数Spatie \ Ssr \ Engines \ V8 :: __ construct()的参数太少

使用类型捕获的无参数方法“传递的位置太少”

Pimple ArgumentCountError:函数的参数太少

致命错误:未被捕获的ArgumentCountError:函数参数太少

检查调用函数时传递了哪些参数

函数调用中传递了多少个参数?

codeigniter 3 '函数 0 的参数太少,预期为 1'

函数具有类型为“int”的参数,但传递了类型为“int*”的参数

参数Google \ Client :: authenticate()的参数太少,第41行在google.php中传递了0,并且正好是1