Illuminate/Database/QueryException with message 'SQLSTATE[42S22]: Column not found: 1054

illuminatedatabasequeryexception sqlstate(42000)
illuminatedatabasequeryexception could not find driver
illuminatedatabasequeryexception sqlstate(42s02)
sqlstate(hy000) (2002) no such file or directory laravel
illuminate\database\queryexception sqlite
could not find driver laravel mysql
catch (exception $e throw new queryexception query, $this->preparebindings($bindings), $e)
illuminate database queryexception sqlstate(hy000) (1049)

I tried to create admin user using php artisan tinker. When I try to save, it return an error. Please help me to fix the issue.

Here is the error

Illuminate/Database/QueryException with message 'SQLSTATE[42S22]: Column not found: 1054 Unknown column 'admin' in 'field list' (SQL: update users set updated_at = 2018-12-28 05:41:31, admin = 1 where id = 1)'

You have no column named 'admin' in 'users' table of your database. Add an 'admin' column. This should solve the error.

Illuminate\Database\QueryException with message 'SQLSTATE , This error can be caused when your database table has not created correctly. You must to create your models and migration files first. To create  Stack Overflow for Teams is a private, secure spot for you and your coworkers to find and share information. Learn more Illuminate\Database\QueryException : SQLSTATE[HY000]: General error: 1364 Field 'user_id' doesn't have a default value (SQL: insert into `users`

Please remove admin in $fillable and try again

Illuminate\Database\QueryException, Create a new query exception instance. string. formatMessage(string $sql, array $bindings, Throwable $previous). Format the SQL error message. string. getSql  Illuminate\Database\QueryException thrown with message "SQLSTATE[23000]: Integrity constraint violation: 1452 Cannot add or update a child row: a foreign key constraint fails (laravelmlg.users, CONSTRAINT users_roles_id_foreign FOREIGN KEY (roles_id) REFERENCES users (id) ON DELETE CASCADE ON UPDATE CASCADE) (SQL: insert into users (username

You must create a migration containing the new columns you want to add to your DB schema.

Example: (this will add a TINYINT admin column with 0 as default value)

<?php

use Illuminate\Support\Facades\Schema;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;

class AddsAdminColumnToUsersTable extends Migration
{
    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        Schema::table('users', function (Blueprint $table) {
            $table->tinyInteger('admin')->default(0);
        });
    }

    /**
     * Reverse the migrations.
     *
     * @return void
     */
    public function down()
    {
        Schema::table('users', function (Blueprint $table) {
            $table->dropColumn('admin');
        });
    }
}

Read more about Laravel Migrations here.

php artisan Error, Hey guys, I have this error upon doing "php artisan migrate": Illuminate\Database\QueryException : SQLSTATE[HY000] [2054] The server reques Illuminate\Database\QueryException : could not find driver (SQL: select * from information_schema.tables where table_schema = blog and table_name = migrations) Please sign in or create an account to participate in this conversation.

Illuminate\Database\QueryException : SQLSTATE[42S01], Illuminate\Database\QueryException : SQLSTATE[42S01]: Base table or view we'll format the error 661| // message to include the bindings with SQL, which  [Illuminate\Database\QueryException] SQLSTATE[HY000]: General error: 1215 Cannot add foreign key constraint (SQL: alter table `videos` add constraint `videos_category_id_foreign` foreign key (`category_id`) references `categories` (`id`)) [PDOException] SQLSTATE[HY000]: General error: 1215 Cannot add foreign key constraint

Class Illuminate\Database\QueryException, // If an exception occurs when attempting to run a query, we'll format the error // message to include the bindings with SQL, which will make this  Illuminate\Database\QueryException with message 'SQLSTATE[42P10]: Invalid column reference: 7 ERROR: for SELECT DISTINCT, ORDER BY expressions must appear in select list LINE 1: select distinct "id" from "users" order by RANDOM() ^ (SQL: select distinct "id" from "users" order by RANDOM())' I can try to submit PR for that, but later

Illuminate\Database\QueryException · Issue #9755 · laravel , Starting' section I get the following error message: Illuminate\Database\​QueryException : SQLSTATE[HY000] [2002] No such file or directo 'custom' => [ 'name' => [ 'required' => 'Please enter book name', ], 'author' => [ 'required' => 'Please enter book author', ], ],

Comments
  • You don`t have admin column in you User table.
  • @Saji show ur User model in question
  • Done. But then return another error "PHP Error: Call to undefined method stdClass::save() in Psy Shell code on line 1"
  • Try this $me = new App\User $me = App\User::find(1) $me->admin = 1 $me->save()