用PHP插入Unicode字符-> ODBC-> MS SQL? [英] Inserting Unicode characters with PHP -> ODBC -> MS SQL?
问题描述
我有以下代码:
$sql = "update tbl_test set category = N'resumé';
echo $sql;
$rs=odbc_exec($conn,$sql);
$ conn是与MSSQL Server的DSN ODBC连接.问题似乎是在PHP和MySQL(也许是ODBC?)之间的Unicode字符转换为垃圾字符.如果我将回显直接说的内容准确地粘贴到企业管理器中,它将插入到MS SQL中.但是,如果我运行代码,它将始终以resumé的形式进入MSSSQL.知道我在这里缺少什么吗?
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?
推荐答案
问题不是ODBC,而是PHP ...解决方案是对从数据库返回的字符串使用utf8_decode().
The problem was not ODBC, but PHP... solution was to use utf8_decode() on the strings returned from the database.
这篇关于用PHP插入Unicode字符-> ODBC-> MS SQL?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!