Undefined offset: 1 Laravel/PHP uploading CSV -


i'm using package > http://csv.thephpleague.com/

but i'm getting undefined offset: 1 when uploading, although csv upload , works error thrown don't client see or think there's problem.

here's method in question:

public function postupload() {     $file = input::file('file');     $name = time() . '-' . $file->getclientoriginalname();     $moved = $file->move(public_path() . '/uploads/csv', $name);      db::table('wc_program_1')->truncate();      $csv = new reader($moved);     $csv->setoffset(0); //because don't want insert header     $nbinsert = $csv->each(function ($row) use (&$sth) {         db::table('wc_program_1')->insert(             array(                  'road' => $row[0],                 'parish' => $row[1],                 'worktype' => $row[2],                 'trafficmanagement' => $row[3],                 'duration' => $row[4],                 'start' => $row[5]             )         );         return true;     });      return redirect::to('admin/programmes')->with('flash_success', 'upload completed & new data inserted.'); } 

and here table structure:

enter image description here

there must more error? undefined offset: 1 in somefile.php on line #4323 or w/e

anyways references missing index array.

the array see $row $row[1] not exist.

if want patch suggest this:

'parish' => (isset($row[1]) ? $row[1] : ''), 

it idea of them such as:

'road' => (isset($row[0]) ? $row[0] : ''), 

Comments

Popular posts from this blog

apache - Remove .php and add trailing slash in url using htaccess not loading css -

javascript - jQuery show full size image on click -