Codeigniter, Severity: error –> Exception: Too few arguments to function, admin dashboard shows HTTP error 500

I am faced with an error in log files
This

ERROR - 2022-05-13 02:47:21 --> Severity: error --> Exception: Too few arguments to function Transactions_model::get_pending_dash(), 0 passed in /Applications/MAMP/htdocs/application/controllers/admin/Dashboard.php on line 47 and exactly 1 expected /Applications/MAMP/htdocs/application/models/Transactions_model.php 2134

Here is exact code under controllers for dashboard.php on line 47:

$transactions = $this->transactions_model->get_pending_dash();

Here is exact code under transactions_model.php models :

  // total transactions ////////////////////////////////////////////
  function total_dash_transactions()
  {
    $s= $this->db->select("COUNT(*) as num")->get("transactions");
    $r = $s->row();
    if(isset($r->num)) return $r->num;
    return 0;

    return $result[0]->Transactions;
  }
    
    function get_pending_dash($user) 
    {
        $where = "status = '1' AND type = '2'";
        return $this->db->where($where)->order_by('id', 'DESC')->limit(20)->get("transactions");
    }

>Solution :

Because in your function get_pending_dash requires $user as a parameter, but based on your code also you did not use it so if you did not use the parameter just delete the $user like the code below.

function get_pending_dash() 
{
    $where = "status = '1' AND type = '2'";
    return $this->db->where($where)->order_by('id', 'DESC')->limit(20)->get("transactions");
}

Leave a Reply