Welcome Guest, Not a member yet? Register   Sign In
Recording insertion problem[ SOLVED ]
#1

[eluser]Redwhirl[/eluser]
Hi,

When I try to add a record I get an error saying that the array $data is an undefinable variable.

Here is the code

Controller
----------
function create_product()
{
$data = array(
'user_prod_name' => $this->input->post('user_prod_name'),
'prod_category' => $this->input->post('prod_category'),
'creation_date' => $this->input->post('creation_date'),
'term' => $this->input->post('term'),
'end_date' => $this->input->post('end_date'),
'bin_price' => $this->input->post('bin_price'),
'user_prod_image' => $this->input->post('user_prod_image'),
'user_prod_down_link' => $this->input->post('user_prod_down_link')
);
$this->load->model('product_model');
$this->product_model->add_record($data);
$this->index();
}

Model
------
function add_record()
{
$this->db->insert('user_products',$data);
return;
}

I looked the code a 100 times and didn't see what's wrong

Thanks for your help
#2

[eluser]Redwhirl[/eluser]
Found it

The model function should be

function add_record($data)




Theme © iAndrew 2016 - Forum software by © MyBB