I am using ODBC to connect to SQL Server with PHP. In PHP, I read the string data (nvarchar) from SQL Server, and then I want to insert it into the mysql database. When I try to insert such a value into the mysql database table, I get this mysql error:
Incorrect string value: '\xB3\xB9ow...' for column 'name' at row 1
For a string with all ASCII characters everything is in order, the problem occurs when there are characters other than ASCII (from some European languages).
Thus, in more general terms: there is a Unicode string in the MS SQL Server database that is retrieved by the ODBC PHP trough. Then it is placed in the sql insert query (as the value for the varchar utf-8 column), which is executed for the mysql database.
Can someone explain to me what is happening in this situation in terms of coding? At what stage can character encodings be converted?
I use: PHP 5.2.5, MySQL5.0.45-community-nt, MS Sql Server 2005.
PHP must run on the Linux platform.
UPDATE: An error does not occur when I call utf8_encode ($ s) on this line and use this value in the mysql insert request, but then the inserted line does not display correctly in mysql (so utf8 encoding worked only to ensure the correct utf8 line, but she was losing the right characters).
php mysql odbc unixodbc odbc-sql-server-driver
Johnm2
source share