0

I am still new in laravel and i got this message error when I am insert using query builder

POST http://localhost:8000/index/bots 500 (Internal Server Error)

and this is in controller

$countries = array("Australia","Japan","Mexico","United States","Italia","Greece","France","Hungary","Estados Unidos","Deutschland","United Kingdom");
            $country = $countries[rand(1,count($countries) - 1)];
            $deviceId = "";
              DB::table('players', 'stats')->insert(array(
                'dealerId' => '1',
                'username' =>  request('botName'),
                'player' => request('botName'),
                'banned' => '0',
                'approve' => '1',
                'winpot' => '100000',
                'deviceId' => '.$deviceId.',
                'myTime' => '0',
                'country' => '.$country.',
                'bot' => '1'
));
kalehmann
  • 4,821
  • 6
  • 26
  • 36
  • what error you got? and `deviceId ` and `$country` no need of `.` (dots) or single quoates. just assign it directly. and try to start the rand from 0 as "Australia" wont be pickedup. according to your logic. – Rafee Sep 12 '18 at 02:02
  • Not sure what caused the issue, but there is another problem in your code: `'country' => '.$country.',` should be `'country' => $country,` – Chaska Sep 12 '18 at 02:14

1 Answers1

0

Generally, a 500 Internal Server means something went wrong on the server side. There are likely two causes for this in your situation:

  1. PHP encountered a syntax error.
  2. A problem exists between your PHP server and your database.

Check your PHP Server logs for more information.

amccormack
  • 13,207
  • 10
  • 38
  • 61