Welcome Guest, Not a member yet? Register   Sign In
PHP Error: Undefined Index
#1

[eluser]Unknown[/eluser]
this is category_controller having three fields cat_id,cat_name,delete_status


function edit_category($cat_id)
{
$css= $this->category_model->get_cat($cat_id);
$data = array(
'cat_id' => $this->input->post('cat_id'),
'cat_name' => $this->input->post('cat_name'),
'delete_status' => $this->input->post('delete_status'),
);

$this->category_model->update_category($cat_id, $data);
$this->data['csss'] = $css;

$data['cat_id']['value'] = $css['cat_id'];
$data['cat_name']['value'] = $css['cat_name'];
$data['delete_status']['value'] = $css['delete_status'];

$this->data['cat_id'] = array(
'name' => 'cat_id',
'id' => 'cat_id',
'type' => 'text',
'style' => 'width:300px;',
//'value' => set_value('cat_id', $css['cat_id']),

);
$this->data['cat_name'] = array(
'name' => 'cat_name',
'id' => 'cat_name',
'type' => 'text',
'style' => 'width:300px;',

);
$this->data['delete_status'] = array(
'name' => 'delete_status',
'id' => 'delete_status',
'type' => 'text',
'style' => 'width:300px;',


);



$this->load->view('edit_category', $this->data);

}

category_model with update function

public function update_category($cat_id, $data)
{
$this->db->where('cat_id', $cat_id);
$this->db->update('saiss_categorymaster', $data);
}


edit_category.php(view)


<?php $this->load->helper('url'); ?>

<?php
$cat_id = $csss['cat_id'];

echo form_open("category/edit/$cat_id");?>
<?php $this->load->helper('form');?>

<?php echo form_input($cat_id);?>
<?php echo form_input($cat_name);?>
<?php echo form_input($delete_status);?>
<input type="submit" name="submit" value="submit"/>
<input type="button" name="btnBack" id="btnBack" value="Back" echo base_url('index.php') ?>/category'" />
<?php echo form_close(); ?>




in this category_controller i got undefined index error i attached the error jpg , kindly help me

and also give me a update data from database code (MVC )

#2

[eluser]Pert[/eluser]
[quote author="sridhar.saiss1" date="1369902308"]
in this category_controller i got undefined index error i attached the error jpg , kindly help me
[/quote]

Can't see the attachment, but undefined index suggest you are trying to access array element that does not exist

Code:
$array = array(
'a' => 'A',
'b' => 'B'
);
$error = $array['c'];

It's always good practise to check if index is actually set first
Code:
$no_error = isset($array['c']) ? $array['c'] : false;
#3

[eluser]TheFuzzy0ne[/eluser]
It helps us a lot when you:
a) Put your code between [code]code tags[/code]
b) Indent your code correctly (using spaces and not tabs).
c) Mention the exact error message, and the line it correlates to in your code.




Theme © iAndrew 2016 - Forum software by © MyBB