Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

Use of undefined constant i – assumed 'i' (this will throw an Error in a future version of PHP) (laravel post method error)

I want to enter an multiple field entered data in table with for loop
but I am getting an error in the post method.

The error is:

Use of undefined constant i – assumed ‘i’ (this will throw an Error in a future version of PHP)

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

controller code:

$degree = $request->degree;
        if($degree > 0)
        {
            for($i=0;$i<count($degree);$i++){
                $edu = new education;
                $edu->degree = $request->degree[i];
                $edu->clg = $request->clg[i];
                $edu->yoc = $request->yoc[i];
                $edu->save();
            }
        }

so, please suggest me what I can do.

>Solution :

here there is a silly mistake bro you not remember to use $i inside loop for the degree, clg and yoc

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading