Reputation:
I am submitting form to /add route BUT when i click on submit button it gives this error Using : Larvel 5
{ SQLSTATE[23000]: Integrity constraint violation: 1062 Duplicate entry '$name' for key 'name' (SQL: insert into
projects
(id
,name
,money
,anything
) values (, $name, 20, asfsf)) }
FORM :
{!! Form::open(array('url' => 'add')) !!}
{!! Form::text('name', '[email protected]') !!}
{!! Form::submit('Click Me!')!}
{!! Form::close() !!}
Routes.php
Route::post('add', function () {
$test = Input::get('name');
echo $test;
});
PS: I want to echo the input field value but it gives the above mentioned error.
Upvotes: 0
Views: 1101
Reputation: 3294
You're inserting nothing for the id. notice the blank space before the comma in values (, $name, 20, asfsf)) }
.
If your id field is set to auto-increment (looks like it is) then remove id
from your insert statement.
insert into projects (name, money, anything) values ($name, 20, 'asfsf')
Upvotes: 1