Currently I have this configuration: Server Windows 2008 R2 Enterprise, Apache 2.4.23, PHP 5.6.25, MySQL 5.7.14
and I'm porting my applications to the a new one with: Server Windows 2019 Datacenter, Apache 2.4.41, PHP 7.4.0, MySQL 8.0.18.
I "copied" some configurations that I know of Apache, PHP, MySQL, headers, in particular those that refer to character encoding like default-charset=iso-8859-1 on php.ini, AddDefaultCharset UTF-8 on httpd.conf, utf8mb4_general_ci collation on MySQL, content="text/html; charset=UTF-8" on headers.
On both I configured with the same parameters an ODBC DSN with iSeries driver pointing to an AS400 db.
To connect with db I use PDO without parameters for charset.
On the actual system I haven't problem with special char like à, °, €: I read from both db, display on html pages. Some applications uses only MySQL, other only ODBC, other both: I get string from AS400 and save on MySQL.
On the new system I'm not able to have the same functionality, because with default_charset=iso-8859-1 only the ODBC applications works well but MySQL's show error like ° as ° or ò as ò, and if I set default_charset=UTF-8 MySQL apps works well and with ODBC ° became �, so I'm not able to get strings from AS400 and save them on MySQL.
My applications are very simple (no framework involved) so PHP code on both systems are the same (I will improve it later).
I think I'm losing some configuration: some suggestion?
Thanks
PS: please let me know if there are other informations that can be useful to know to catch a solution.
EDIT
As punctual solution I can, having default-charset=utf-8, use utf8_encode with strings from ODBC, but before change all the code I will try to find a global solution.
EDIT 2: applications
As requested I give some additional informations on my app, if useful.
- AS400 db is managed by an ERP, so I use it only in read mode. Some apps send query via PDO and display results (eg Sales).
- MySQL db is used to store data not managed by ERP (eg Quality). Apps do CRUD operations via PDO using data inserted by users.
- Mixed apps retrive some data from AS400 (eg Products), some data from users and save on MySQL.
- "Mirror" tables are created on MySQL to contain views of AS400 tables (for better response). An app periodically get data from AS400 and store them on MySQL.
EDIT 3: on mysql driver/connection/configuration
After doing a test with the same code having an echo '°' and a print_r($mysql_data) with these results:
- actual: echo=>° print_r=>°
- new: echo=>° print_r=>°
I am convinced that the "problem" is on the MySQL connection, maybe something I had set and don't remember :-(