Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Inserting Unicode characters with PHP -> ODBC -> MS SQL?

Tags:

I have the following code:

$sql = "update tbl_test set category = N'resumé';

echo $sql;

$rs=odbc_exec($conn,$sql);

Where $conn is a DSN ODBC connection to an MSSQL Server. The problem seems to be that somewhere between PHP and MySQL (Maybe ODBC?) unicode characters are converted to junk. If I copy paste exactly what the echo says directly into Enterprise Manager, it inserts into MS SQL fine. If I run the code however, it always goes into MSSSQL as resumé . Any idea what I'm missing here?

like image 391
catbelly Avatar asked Aug 05 '09 03:08

catbelly


1 Answers

The problem was not ODBC, but PHP... solution was to use utf8_decode() on the strings returned from the database.

like image 65
catbelly Avatar answered Oct 11 '22 23:10

catbelly