I am currently stuck at a problem in our project where I read text out of the Database, modify it somewhat and then save it back again. The data is saved in an ntext-field (and is actually an XML-document). Ther error I'm receiving is:
Zend_Db_Statement_Exception: SQLSTATE[HY000]: General error: 2402 [FreeTDS][SQL Server]Error converting characters into server's character set. Some character(s) could not be converted (SQLExecute[2402] at /build/php5-F6w79J/php5-5.5.9+dfsg/ext/pdo_odbc/odbc_stmt.c:254)
We are working with:
- PHP 5.5.9-1ubuntu4
- Freetds-Version 7.2 (and client charset = UTF-8)
- Microsoft SQL Server 2012
I suspect the error has something to do with the encoding of the data. It works quite fine with most of the database-entries, but with some it throws the aforementioned error. There seems to be some characters whose encoding gets mixed up somewhere on their way from the database to php and back again. If the problematic XML is saved to a file and opened there is an error which says that the XML is not well-formed (although if I copy the xml directly from the database into an xml-validator everything is alright). We already tried filtering out any controll-characters that might be problematic and also looked this error up - but so far no answer really worked for me. Has anyone an idea where this error might originate? It would also help if I could determine which characters are causing this problem, maybe I could filter them out before writing the data back to the database.
If any additional information is required I'll gladly be of help.
Greetings,
Sajus