0

I'm trying to load data from a MySQL DB from a varchar(35) / utf8_swedish_ci field through TBS (tinybutstrong) and PHP using the example (MySQL data merge). My issue is that data loads fine if only ascii characters are in the fields but as soon as I add a single scandinavian special character like ö or ä the field contents vanishes entirely and other fields in row display correctly.

My understanding is that the latest versions on TBS automatically use UTF-8 coding (I have 3.9.0 for PHP 5) so I assumed it would work out-of-the-box. To be safe, I even added the coding to template as so:

'$TBS->LoadTemplate('mysql.html','UTF-8');' but to no avail.

Could someone please advice what is causing this.

sakumatto
  • 157
  • 1
  • 9

1 Answers1

0

For a good UTF-8 processing, all elements of the chain must be UTF-8.

You have to ensure that your template is UTF-8 : check the entered text and the HTML element <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />

You have to ensure that all your PHP scripts are UTF-8 and not Ansi.

You also have to ensure that your MySQL connection is set to receive UTF-8 queries and to return UTF-8 item data. This can be done for example by querying the SQL : SET NAMES 'UTF8'

Skrol29
  • 5,402
  • 1
  • 20
  • 25
  • Thanks for your kind answer. Here's what I did: In MySQL I ran 3 commands - ALTER DATABASE stadinru_paivystaja CHARACTER SET utf8 COLLATE utf8_swedish_ci; - ALTER TABLE tilaus_table CONVERT TO CHARACTER SET utf8 COLLATE utf8_swedish_ci; - ALTER TABLE tilaus_table MODIFY tilaus_custname VARCHAR(35) CHARACTER SET utf8 COLLATE utf8_swedish_ci; In php I checked this setting is present: My php.ini contains this: default_charset = "utf-8" My template.html file contains Both files .php and .html have been edited under utf-8. – sakumatto Jun 07 '15 at 05:17
  • But still the scandic characters were not showing.\r \r Then finally I added the command mysql_query("set names 'utf8'"); into the php file and that helped, now the scandic characters are showing correctly. Thanks a lot! – sakumatto Jun 07 '15 at 05:31