Hi to all i experience this kind of error when i tried to add the data to database using for each here is my code.

$org   = Input::get('orgname');
        $orgs_date = Input::get('orgsattended');
        foreach($org as $o=>$von){
        DB::table('orgs')->insert(array(
            'personnel_id'           => $personnel_id,
            'orgs_name'              => $von,
            'date_attended'          => $org_date[$o]
        )
        );
        }
$skillname = Input::get('skillname');
        $skillproficiency = Input::get('skillproficiency');
        foreach($skillname as $sn=>$vsn){
            DB::table('skills')->insert(array(
                'personnel_id'       => $personnel_id,            
                'skill_name'         => $vsn,       
                'proficiency'        => $skillproficiency[$sn]       
                )
            );


    }

i need to add the data to seperate database.
when i only use one code it works.

Recommended Answers

All 2 Replies

Member Avatar for diafol

Hi to all i experience this kind of error when i tried to add the data to database using for each here is my code.

What error? ARe you talking about the "invalid argument...foreach()"?

This often occurs if the "array" in the foreach statement is not actually an array for whatever reason.

i need to add the data to seperate database.
when i only use one code it works.

What are you trying to say? What separate DB? Which one code? Are you saying a single value of $skillname?

Your indenting is all over the place. Sloppy presentation of code suggests sloppy coding. I'm sure that's not the case, so please reformat your code and you may get more replies.

What separate DB?

i think he meant separate tables in the database. would one need multiple databases though? i didn't think multiple databases was needed in any one project.

also maybe post the html that might also help the experts here to help you out. help them, help you.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.