0
votes

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

2
Is it possible you some sort of SQL trigger that causes that? - Joseph Silber
im not using any SQL triggers - Dr.Neo
what is your migration? - Pete Houston

2 Answers

0
votes

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.

0
votes

The column FirstName does not exist in the table, but I can see that you have a column Name maybe that's the one.