0

A PHP Error was encountered

Severity: Notice

Message: Undefined offset: 2 Filename: controllers/mycontrollers.php Line Number: 721 how i solve it?

CODE:

$serial_number_array = json_decode($this->input->post('serial_number_array_session'));
        if (isset($serial_number_array)) {
                if ($serial_number_array == null) {                   
                } else {
                    $Serial_number_info_array = array();
                    foreach ($serial_number_array as $value) {
                        $Serial_number_info_array['Issue_Number'] = $Issue;
                        $Serial_number_info_array['status_serial_item'] = 1;
                        $Item_name = $value->Item_Name_session;
                        for ($a = 0; $a <= $loop_serial_number; $a++) {
                            ***$serial_number = $value->serial_number_session["$a"];***
                            $this->Inventory_model->Update_serial_number_model($Item_name,$serial_number,$Serial_number_info_array);
                        }
                    }
                }
            }
  • your `$loop_serial_number` is no where define and you are using it in `for` loop? It will give you error – Alive to die - Anant Sep 20 '17 at 12:23
  • i think you don't have the array length up to 3, and you are trying to access that index – RAUSHAN KUMAR Sep 20 '17 at 12:23
  • And, Change `$serial_number = $value->serial_number_session["$a"];` to `$serial_number = $value->serial_number_session[$a];` – Nana Partykar Sep 20 '17 at 12:24
  • i do that: $serial_number = $value->serial_number_session[$a]; But same error show. – golam moktadir Sep 20 '17 at 12:28
  • Then, what about @AlivetoDie Question's? – Nana Partykar Sep 20 '17 at 12:28
  • i could not understand what you say about @AlivetoDie Question's? – golam moktadir Sep 20 '17 at 12:34
  • *..your $loop_serial_number is no where define and you are using it in for loop?* From where, `$loop_serial_number` coming into picture? – Nana Partykar Sep 20 '17 at 12:35
  • @golammoktadir replace your for loop with this `for ($a = 0; $a <= $loop_serial_number; $a++) { if ( isset($value->serial_number_session["$a"]) ) { $serial_number = $value->serial_number_session["$a"]; $this->Inventory_model->Update_serial_number_model($Item_name,$serial_number,$Serial_number_info_array); } else { /*else part of code*/ } }` it will work fine. – Harish Sep 20 '17 at 16:37
  • Its a little messy in the comment but you should give it a try :) – Harish Sep 20 '17 at 16:39
  • Hey I updated your question - (updated the for loop only) have a look and may it works for you. – Harish Sep 20 '17 at 16:46

0 Answers0