laravel を使って適当にログイン画面を作っています。
以下のindex.blade.phpにてID、PWを送信し、コントローラー内でそのデータをsqlite内のテーブルに挿入するという操作をしたいのですが。
送信するとSQLSTATE[HY000]: General error: 1 no such table: member (SQL: insert into member (ID, PW) values (:ID, :PW))というエラーが発生します。
.envのSESSION_DRIVERはfileに設定されています。
↓index.blade.php
<!DOCTYPE html> <html lang="ja"> <head> <meta charset="utf-8"> <title>Login Practice</title> </head> <body> <h1> Wellcome!</h1> <form action="/login/clear" method="post"> @csrf <table> <tr><th>ID:</th><td><input type="text" name="id"></td></tr> <tr><th>PW:</th><td><input type="text" name="pw"></td></tr> <tr><th></th><td><input type="submit" value="send"></td></tr> </table> </form> </body> </html>
↓LoginController.php
<?php namespace App\Http\Controllers; use Illuminate\Http\Request; use Illuminate\Http\Response; use Illuminate\Support\Facades\DB; class LoginController extends Controller { public function index(){ return view('login.index'); } public function clear(Request $request){ $in = [ 'ID' => $request->id, 'PW' => $request->pw, ]; DB::insert('insert into member (ID, PW) values (:ID, :PW)', $in); $data = DB::select('select * from member'); return view('login.clear', ['cells' => '$data']); } }
エラー発生源を下記にのせておきます。
C:\Users\fghjz.LAPTOP-VM64TKHN\Desktop\laravelapp\vendor\laravel\framework\src\Illuminate\Database\Connection.php:669
throw new QueryException( 下記のこの部分が669行目になります。
{ // To execute the statement, we'll simply call the callback, which will actually // run the SQL against the PDO connection. Then we can calculate the time it // took to execute and log the query SQL, bindings and time in our memory. try { $result = $callback($query, $bindings); } // 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 exception a // lot more helpful to the developer instead of just the database's errors. catch (Exception $e) { throw new QueryException( $query, $this->prepareBindings($bindings), $e ); } return $result; }
回答2件
あなたの回答
tips
プレビュー