Nida Akram
Nida Akram

Reputation: 362

SQLSTATE[42S22]: Column not found:

I am getting this error unknown column city = Faislabad but i have this column in my database. I want to fetch the data in which city is faislabad.

Code of my controller is

       public function chart(Request $request)
        {
             $users = Disease::where("city=$request->city")

                ->get();

    $chart = Charts::database($users, 'bar', 'highcharts')

              ->title("Monthly new Register Users")

              ->elementLabel("Total Users")

              ->dimensions(1000, 500)

              ->responsive(false)

              ->groupBy('name');

    return view('test1',compact('chart'));  
        }

And the migration for my table is

   public function up()
{
    Schema::create('diseases', function (Blueprint $table) {
        $table->increments('id');
        $table->string('name');
        $table->string('city');
        $table->string('symptomps');
    });
}

Please tell me what I am doing wrong in this.

Upvotes: 1

Views: 75

Answers (1)

Raza Mehdi
Raza Mehdi

Reputation: 941

Change:

$users = Disease::where("city=$request->city")->get();

to

$users = Disease::where('city', $request->city)->get();  

Upvotes: 2

Related Questions