0

Slowly moving a project into Laravel. Using a loop I'm capturing all the form input arrays.

The exception is thrown on:

$data[] = "['job_id' => '$jobID', 'first_name' => '$name', 'dob' => '$dob']";

Larger context:

$jobID = 2;
$data = array();
foreach(Input::get('name') as $row=>$name){

    $name = Input::get('name');
    $dob = Input::get('dob'.$row);

    $data[] = "['job_id' => '$jobID', 'first_name' => '$name', 'dob' => '$dob']";

}

$data_insert = implode(',', $data);

if(!empty($name)) {
    DB::table('job_data')->insert([
        $data_insert
    ]);

}
3
  • Probably because $jobID isn't defined. Commented Jun 16, 2016 at 16:51
  • It is defined in the function. I will drop it in so that does not distract from the actual error. Thanks Commented Jun 16, 2016 at 16:57
  • Why is your array a string? Commented Jun 16, 2016 at 17:08

1 Answer 1

2

I'm guessing $name = Input::get('name'); returns an array. Try removing the line completely, it's unecessary because $name is already defined.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.