2

My site has a webform and its submission data is written to a Microsoft SQL Server table. My site is built on a PHP / Apache / Ubuntu-Server stack.

The charset of the website is UTF-8, but the charset of the SQL Server is latin_1. As a result, the strings are corrupted when they are stored in the database.

It is not posible to change the charset of the SQL Server to UTF-8.

Of course, Microsoft supports a driver to fix this problem, but the driver is only for Microsoft operating systems.

I switched the charset of the webform to ISO-8859-1 (which isn't identical to latin_1), but then if I write Müller into the form, I get Mller in the database. After some researching, I found out that the "normal" Linux driver doesn't support this charset.

Where can I get a driver to write some text with correct charset from PHP to Microsoft SQL Server?

mickmackusa
  • 852
  • 1
  • 9
  • 18
user2111880
  • 123
  • 3

1 Answers1

0

I have never work before with an Microsoft SQL, but I think there is far simpler solution than change encoding of whole PHP script.

There is a function (mb_convert_encoding) which converts the character encoding of string, so I think you can build queries using it.

Check reference on PHP Documentation.

roomcayz
  • 453
  • 3
  • 10
  • i am still a little bit confused what happens here, but it works :) - i just have some little trouble left with the euro sign... but i think this shoud be a solveable problem. - thanks – user2111880 May 21 '14 at 08:40