За последние 24 часа нас посетили 17185 программистов и 1650 роботов. Сейчас ищут 1033 программиста ...

Как исправить 3/3 QueryException in Connection.php line 770: ?

Тема в разделе "Laravel", создана пользователем boss1, 20 фев 2021.

  1. boss1

    boss1 Новичок

    С нами с:
    18 фев 2021
    Сообщения:
    70
    Симпатии:
    0
    PHP:
    1. <?php
    2.  
    3. namespace App\Http\Controllers\Admin;
    4.  
    5. use Illuminate\Http\Request;
    6.  
    7. use App\Http\Requests;
    8. use App\Http\Controllers\Controller;
    9. use Illuminate\Http\Response;
    10. use Illuminate\Http\RedirectResponse;
    11. use DB;
    12.  
    13. class AboutController extends Controller
    14. {
    15.     //
    16.     public function show() {
    17.  
    18.         if(view()->exists('default.about')) {
    19.  
    20. //            $artiles = DB::select("SELECT * FROm `articles` WHERE id = :id",['id'=>2]);
    21.  
    22.             DB::insert("INSERT INTO `articles` (`name`,`text`) VALUES (?, ?)", ['test 1','TEXT']);
    23.             $artiles = DB::select("SELECT * FROm `articles` ");
    24.  
    25.             //$result = DB::connection()->getPdo()->lastInsertId();
    26.  
    27. //$result = DB::update('UPDATE  `articles` SET `name` = ? WHERE `id` = ?', ["TEST 2",6]);
    28. //$result = DB::update('UPDATE  `articles` SET `name` = ? WHERE `id` = ?', ["TEST 3",6]);
    29.  
    30.             //$result = DB::delete('DELETE FROM `articles` WHERE `id` = ?', [6]);
    31.  
    32.             //DB::statement('DROP table `articles`');
    33.  
    34. //            $artiles = DB::select("SELECT * FROm `articles");
    35. //
    36. //            //dump($result);
    37.             dump($artiles);    //dd()
    38. //
    39. //            foreach($artiles as $article) {
    40. //
    41. //            }
    42.             return view('default.about')->withTitle('Hello World');
    43.  
    44.         }
    45.         abort(404);
    46.     }
    47.  
    48. }
    --- Добавлено ---
    Whoops, looks like something went wrong.
    3/3 QueryException in Connection.php line 770: SQLSTATE[HY000]: General error: 1364 Field 'img' doesn't have a default value (SQL: INSERT INTO `articles` (`name`,`text`) VALUES (test 1, TEXT))
    1. in Connection.php line 770
    2. at Connection->runQueryCallback('INSERT INTO `articles` (`name`,`text`) VALUES (?, ?)', array('test 1', 'TEXT'), object(Closure)) in Connection.php line 726
    3. at Connection->run('INSERT INTO `articles` (`name`,`text`) VALUES (?, ?)', array('test 1', 'TEXT'), object(Closure)) in Connection.php line 481
    4. at Connection->statement('INSERT INTO `articles` (`name`,`text`) VALUES (?, ?)', array('test 1', 'TEXT')) in Connection.php line 435
    5. at Connection->insert('INSERT INTO `articles` (`name`,`text`) VALUES (?, ?)', array('test 1', 'TEXT')) in DatabaseManager.php line 317
    6. at DatabaseManager->__call('insert', array('INSERT INTO `articles` (`name`,`text`) VALUES (?, ?)', array('test 1', 'TEXT'))) in Facade.php line 237
    7. at Facade::__callStatic('insert', array('INSERT INTO `articles` (`name`,`text`) VALUES (?, ?)', array('test 1', 'TEXT'))) in AboutController.php line 22
    8. at AboutController->show()
    9. at call_user_func_array(array(object(AboutController), 'show'), array()) in Controller.php line 55
    10. at Controller->callAction('show', array()) in ControllerDispatcher.php line 44
    11. at ControllerDispatcher->dispatch(object(Route), object(AboutController), 'show') in Route.php line 189
    12. at Route->runController() in Route.php line 144
    13. at Route->run(object(Request)) in Router.php line 653
    14. at Router->Illuminate\Routing\{closure}(object(Request)) in Pipeline.php line 53
    15. at Pipeline->Illuminate\Routing\{closure}(object(Request)) in Mymiddleware.php line 29
    16. at Mymiddleware->handle(object(Request), object(Closure)) in Pipeline.php line 137
    17. at Pipeline->Illuminate\Pipeline\{closure}(object(Request)) in Pipeline.php line 33
    18. at Pipeline->Illuminate\Routing\{closure}(object(Request)) in SubstituteBindings.php line 41
    19. at SubstituteBindings->handle(object(Request), object(Closure)) in Pipeline.php line 137
    20. at Pipeline->Illuminate\Pipeline\{closure}(object(Request)) in Pipeline.php line 33
    21. at Pipeline->Illuminate\Routing\{closure}(object(Request)) in VerifyCsrfToken.php line 65
    22. at VerifyCsrfToken->handle(object(Request), object(Closure)) in Pipeline.php line 137
    23. at Pipeline->Illuminate\Pipeline\{closure}(object(Request)) in Pipeline.php line 33
    24. at Pipeline->Illuminate\Routing\{closure}(object(Request)) in ShareErrorsFromSession.php line 49
    25. at ShareErrorsFromSession->handle(object(Request), object(Closure)) in Pipeline.php line 137
    26. at Pipeline->Illuminate\Pipeline\{closure}(object(Request)) in Pipeline.php line 33
    27. at Pipeline->Illuminate\Routing\{closure}(object(Request)) in StartSession.php line 64
    28. at StartSession->handle(object(Request), object(Closure)) in Pipeline.php line 137
    29. at Pipeline->Illuminate\Pipeline\{closure}(object(Request)) in Pipeline.php line 33
    30. at Pipeline->Illuminate\Routing\{closure}(object(Request)) in AddQueuedCookiesToResponse.php line 37
    31. at AddQueuedCookiesToResponse->handle(object(Request), object(Closure)) in Pipeline.php line 137
    32. at Pipeline->Illuminate\Pipeline\{closure}(object(Request)) in Pipeline.php line 33
    33. at Pipeline->Illuminate\Routing\{closure}(object(Request)) in EncryptCookies.php line 59
    34. at EncryptCookies->handle(object(Request), object(Closure)) in Pipeline.php line 137
    35. at Pipeline->Illuminate\Pipeline\{closure}(object(Request)) in Pipeline.php line 33
    36. at Pipeline->Illuminate\Routing\{closure}(object(Request)) in Pipeline.php line 104
    37. at Pipeline->then(object(Closure)) in Router.php line 655
    38. at Router->runRouteWithinStack(object(Route), object(Request)) in Router.php line 629
    39. at Router->dispatchToRoute(object(Request)) in Router.php line 607
    40. at Router->dispatch(object(Request)) in Kernel.php line 268
    41. at Kernel->Illuminate\Foundation\Http\{closure}(object(Request)) in Pipeline.php line 53
    42. at Pipeline->Illuminate\Routing\{closure}(object(Request)) in StartSession.php line 64
    43. at StartSession->handle(object(Request), object(Closure)) in Pipeline.php line 137
    44. at Pipeline->Illuminate\Pipeline\{closure}(object(Request)) in Pipeline.php line 33
    45. at Pipeline->Illuminate\Routing\{closure}(object(Request)) in CheckForMaintenanceMode.php line 46
    46. at CheckForMaintenanceMode->handle(object(Request), object(Closure)) in Pipeline.php line 137
    47. at Pipeline->Illuminate\Pipeline\{closure}(object(Request)) in Pipeline.php line 33
    48. at Pipeline->Illuminate\Routing\{closure}(object(Request)) in Pipeline.php line 104
    49. at Pipeline->then(object(Closure)) in Kernel.php line 150
    50. at Kernel->sendRequestThroughRouter(object(Request)) in Kernel.php line 117
    51. at Kernel->handle(object(Request)) in index.php line 53
    с
     
  2. ADSoft

    ADSoft Старожил

    С нами с:
    12 мар 2007
    Сообщения:
    3.854
    Симпатии:
    748
    Адрес:
    Татарстан
    Текст ошибки просто перевести хотя бы не пробовали?
     
  3. boss1

    boss1 Новичок

    С нами с:
    18 фев 2021
    Сообщения:
    70
    Симпатии:
    0
    Спасибо перевел и исправил