0

I save file in .csv format in UTF-8 eoncoding.

screen1

Sample title: 209508,Moschino Toy Boy woda perfumowana Ć w sprayu 100ml,1

title contains PL characters Ć Ś Ó etc.

Now I load csv, then convert to HTML table and then import to DB.

Screen from table html, still display correct:

screen table

and after import the result in database is:

Moschino Toy Boy woda perfumowana Ć w sprayu 100ml

Not support PL characters. How to resolve this isse?

This is my code for import:

 session_start();

$file_data = $_SESSION['file_data'];

unset($_SESSION['file_data']);

foreach ($file_data as $row) {
    $data = $row[$_POST["sku"]];
    $title = $row[$_POST["title"]];
    $lang_id = $row[$_POST["lang_id"]];

    if (isset($data)) {
        $statement = $connect->prepare("UPDATE product_details  SET title = '$title'
        WHERE sku = '$data' AND lang_id = '$lang_id'");

        if (!$statement->execute()) {
            $error = 'None or part of the data was updated';
        }
    }
}
echo $error ?? 'Data Updated Successfully';
}

Please note: When I manuall add product from ecommerce system then working and correct display in database Ć Ś, issue is only when I import products.

  • What did the result look like? This might give you better clues: https://stackoverflow.com/questions/38363566/trouble-with-utf8-characters-what-i-see-is-not-what-i-stored – Rick James Nov 26 '22 at 19:26
  • 1
    @Rick James this $dbConnection = new PDO('mysql:dbname=dbtest;host=127.0.0.1;charset=utf8mb4', 'user', 'password'); solved my issue. – Marcin Wierzycki Nov 26 '22 at 19:27

0 Answers0