i need to add a simple form data into the database with laravel
each time the form posted the data goes into the database but i got this error
SQLSTATE[42S22]: Column not found: 1054 Unknown column 'tf.FirstName' in 'field list' (SQL: insert into `tbl_fundraising_pages` (`Permalink`, `Name`, `Summary`, `Story`, `Goal_Amount`, `End_Date`, `Designation`, `WebAddress`, `Block_SearchEngine`, `CharityID`, `updated_at`, `created_at`) values (Something-Like-That, Something Like That, Something Like That, <p>Something Like That</p> , 500, 11/04/2014, General Fund, Something-Like-That, NewDesig, 1387, 2014-11-21 15:14:19, 2014-11-21 15:14:19)
there is no tf.FirstName filed in the database neither the query Modal
<?php
class Fundraising extends Eloquent{
protected $table = 'tbl_fundraising_pages';
protected $fillable = [
'fundraiser_id',
'Permalink',
'Name',
'Summary',
'Story',
'Goal_Amount',
'End_Date',
'Designation',
'WebAddress',
'Block_SearchEngine',
'CharityID'
];
}
Controller Function
public function postCreatePage(){
$charities = Charities::where('Charity_Name','=',''.Input::get('NonprofitName').'')->first();
$data = array(
'Permalink' => str_replace(' ', '-', Input::get('FundraiserName')),
'Name' => Input::get('FundraiserName'),
'Summary' => Input::get('Summary'),
'Story' => Input::get('YourPassion'),
'Goal_Amount' => Input::get('GoalAmount'),
'Designation' => Input::get('Designation'),
'WebAddress' => str_replace(' ', '-', Input::get('FundraiserName')),
'Block_SearchEngine' => Input::get('NewDesig')
);
if(Input::get('NonprofitName')){
$data['CharityID'] = $charities->ID;
}
$page = new Fundraising();
foreach ($data as $key => $insert){
$page->$key = $insert;
}
if($page->save()){
return Response::json(array('message' => 'Done'));
}
}
i have no clue from where this filed is coming ?
nothing in the HTML form nothing in the Ajax call
Probably, somewhere in your migration, there defines the FirstName
column as the error tells us about Unknown column 'tf.FirstName'
. As you controller not doing anything with this column, I suggest to find it and remove.
表中不存在FirstName
列,但我可以看到您有一个Name
列,也许就是那个。
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.