0

I am trying to insert data from a CSV file to the database and everything is working but if any string comes with any German special character like öüäß then I get the following error displayed:

b"SQLSTATE[22007]: Invalid datetime format: 1366 Incorrect string value: '\xE4.' for column 'name' at row 1 (SQL: insert into `ergebnisses` (`stadt`, `lauf_jahr`, ▶"

controller:

public function index()
    {
        $collection = (new FastExcel)->configureCsv(';')->import('C:\Users\mussa\Desktop\file.csv', function ($line) {
            return Ergebnisse::create([
                'stadt' => 'hamburg',
                'lauf_jahr' => '2019',
                'lauf_strecke' => '4',
                'MWPl' => $line['MWPl'],
                'start_number' => $line['Startnr.'],
                'name' => $line['Name'],
                'birth_year' => $line['Jahrg.'],
                'm/w' => $line['m/w'],
                'AK' => $line['AK'],
                'verein' => $line['Verein'],
                'zeit' => $line['Zeit'],
            ]);
        });
        // dd($collection);
    }

Collection data:

Collection data

any help would be really appreciated, I am new to Laravel.

Best Regards Musayyab Naveed

Musayyab Naveed
  • 365
  • 5
  • 14
  • maybe [using the charset utf8mb4 and the collation utf8mb4_unicode_ci in MySQL](https://stackoverflow.com/questions/5526169/what-is-the-best-mysql-collation-for-german-language/48325386#48325386) ? – porloscerros Ψ Jun 03 '19 at 00:15

2 Answers2

0

Change your column datatype string instead of DateTime

Or

If you don't want to change your column datatype then enter date in a correct format.

Community
  • 1
  • 1
0

Use Datatype "string" in migration for name column

PHP Geek
  • 3,949
  • 1
  • 16
  • 32