0
votes

So I'm trying to make an account-based website using Laravel 5.5.

I have a database table 'users' where it has:

id - int(10)[PRIMARY_KEY],

created_at - timestamp,

updated_at - timestamp,

username - varchar [FOREIGN_KEY]

password - varchar

I already have username and password in my database

username: vanderozili

password: jaujaujau

when i'm trying to login using this validation

$validation = Validator::make( $request->all(), [
                'username' => 'username|required',
                'password' => 'required|min:8'
            ]);

            if(Auth::attempt(['username', $request->input('username'), 'password', $request->input('password')])){
                return redirect('/shop');
            }

            return redirect()->back();
        }

I'm encountering this error.

(2/2) QueryException

SQLSTATE[42S22]: Column not found: 1054 Unknown column '0' in 'where clause' (SQL: select * from users where 0 = username and 1 = vanderozili and 2 = password and 3 = jaujaujau limit 1)

I'm using mysql thru phpmyadmin

I already searched it online but I can't see a similar problem as I'm experiencing. What seems to be the problem?

1
which RDBMS are you using here?Funk Forty Niner
oh sorry I forgot to mention it. I'm using mysql thru phpmyadminjaucabiles
@MarkBaker I had done a wrong close and reopened it. I feel you should most likely post your comment as an answer IMHO.Funk Forty Niner
Thanks @MarkBaker ;-)Funk Forty Niner

1 Answers

1
votes

This args should be an associative array of column name/value pairs, not a simple series of array values:

if(Auth::attempt(['username' => $request->input('username'), 'password' => $request->input('password')])){`

as shown in the Laravel Docs