skip to Main Content

I have a Problem getting UTF-8 encoded Strings out of a MariaDB-Database. Today I updated my XAMPP-Distro to 10.4.11-MariaDB (MySql) and PHP 7.2.29 and now a strange Problem arised wich had not occoured with the older version.

Preliminary informations:
I am importing data from a database dump from a working MariaDB-Database (productive system) to my local Database. And on the local Database the problem occours.

When I send a query on the local system to the database via PHP (mysqli) (the code is the same as on the production system) I get the wrong encoding:

wrong encoding of text which did not occour on the previous XAMPP installation and does not occour on the production system

If I wrap the text from the database with the following php function

utf8_decode($textFromTheDatabase);

everything works fine.

I also tried the following lines before every query but this does not change anything:

$dbConnection->set_charset('utf8');
$dbConnection->query("SET NAMES 'utf8'");

As mentioned above everything works on the production system but not on the new XAMPP installation. When I still had the old XAMPP version on my local system everything worked fine. So I think something is wrong with the configuration of my local Database or PHP or Apache?

2

Answers


  1. Chosen as BEST ANSWER

    Ok now I have a solution for the Problem: I updated to XAMPP 7.4.4 with PHP 7.4.4 and MariaDB 10.4.11. Then I set the character set and the collation correctly:

    character-set-server = latin1
    collation-server = latin1_swedish_ci
    

    then it worked


  2. Don’t use any decode functions; that just makes things worse.

    Your images shows the “Mojibake” problem. The causes for that are discussed here:
    Trouble with UTF-8 characters; what I see is not what I stored

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search