Skip to content
Advertisement

How to Add data to Database in Laravels

I will to add data to database, but I have an error when I write the code to add data to array, and the error like this,

syntax error, unexpected ‘=’, expecting ‘]’

I am using the follwing code:

Controller

JavaScript

Here’s the view

JavaScript

Here’s the route

JavaScript

Do you have any solution to this? I have also tried:

JavaScript

but that also gives an error.

Advertisement

Answer

You seem to have mixed the old array syntax array() and the new syntax []. Keep in mind each entry of the array has to end with an , instead of a ;.

You could use the following:

JavaScript
User contributions licensed under: CC BY-SA
3 People found this is helpful
Advertisement