-1

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?

Dharman
  • 30,962
  • 25
  • 85
  • 135
  • No this does not solve my question. Everything mentioned there I tried! – badhazelnoot Apr 17 '20 at 15:53
  • ok downgrading to XAMPP version 7.1.26-1 solves the problem... but why does it work with this version but not with a newer one? – badhazelnoot Apr 17 '20 at 16:13
  • That probably changed MariaDB and PHP version. What are they now? – Dave Apr 17 '20 at 16:32
  • Now the (downgraded) versions are: PHP-Version: 7.1.26, 10.1.38-MariaDB – badhazelnoot Apr 17 '20 at 16:36
  • If this is an ongoing need I would update PHP to the latest version, 7.4.4, and see if things still work. Then I'd go for the latest MariaDB version which is 10.4.12. The version of PHP you are at now is end of life and no longer supported. – Dave Apr 17 '20 at 16:40
  • Does your "working MariaDB-Database (productive system)" stores data as Swedish latin1? – ikiK Apr 17 '20 at 16:54
  • Does your "working MariaDB-Database (productive system)" stores data as Swedish latin1? -> YES! – badhazelnoot Apr 17 '20 at 17:01
  • I am not able to only update the php version in xampp it always comes with the corresponding MariaDB version... i've upgraded now to XAMPP 7.4.4 with MariaDB 10.4.11 - same problem – badhazelnoot Apr 17 '20 at 17:29

2 Answers2

0

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

Rick James
  • 135,179
  • 13
  • 127
  • 222
  • That was my problem. I do not want to use decode functions. The only thing I wanted to say is that it works with a decode function. – badhazelnoot Apr 26 '20 at 07:04
-1

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