Reputation: 115
I'm working on a project & I've encounter with this problem "Argument Count Error". I've checked code by code but did not find anything.
Controller Code:
public function new_package(){
$name = $this->input->post('name');
$price = $this->input->post('price');
$description = $this->input->post('description');
if($name != '' && $price != '' && $description != ''){
$packageData = $this->Process->package_add($name, $price, $description);
if($packageData){
$added = "Package Added";
$this->session->set_flashdata('added', $added);
redirect('Packages');
}
}
else{
$blank = "Please Fill Required Fields.";
$this->session->set_flashdata('blank', $blank);
redirect('Packages');
}
}
Modal Code:
public function package_add($name, $price, $description){
$insertData = array(
'title' => $name,
'price' => $price,
'description' => $description
);
$insertQuery = $this->db->insert('packages', $insertData);
if($insertQuery){
return TRUE;
}
else{
return FALSE;
}
}
Modal name Process.
Error: ""Type: ArgumentCountError
Message: Too few arguments to function Process::package_add(), 0 passed in C:\xampp\htdocs\apn_new\backend\application\controllers\Packages.php on line 32 and exactly 3 expected
Filename: C:\xampp\htdocs\apn_new\backend\application\models\Process.php
Line Number: 299""
I've search over this site related this type problem but I did not find my problem solution. This problem comes before submit form. Please Help me.
Thank You
Upvotes: 0
Views: 687
Reputation: 654
Create insert array in controller
Controller.php
public function new_package(){
$name = $this->input->post('name');
$price = $this->input->post('price');
$description = $this->input->post('description');
if($name != '' && $price != '' && $description != ''){
$insertData = array(
'title' => $name,
'price' => $price,
'description' => $description
);
$packageData = $this->Process->package_add($insertData);
if($packageData){
$added = "Package Added";
$this->session->set_flashdata('added', $added);
redirect('Packages');
}
}
else{
$blank = "Please Fill Required Fields.";
$this->session->set_flashdata('blank', $blank);
redirect('Packages');
}
}
Model.php
public function package_add($insertData){
$insertQuery = $this->db->insert('packages', $insertData);
if($insertQuery){
return TRUE;
}
else{
return FALSE;
}
}
Upvotes: 1