社区论坛(簡體)

使用php_dblib.dll访问ms sqlserver2000乱码,求助?

 
kgq haoyun的相片
使用php_dblib.dll访问ms sqlserver2000乱码,求助?
 

各位朋友,我在使用php_dblib.dll获取ms sqlserver2000数据时乱码,
但是向sqlserver写入数据是正常的,弄好好久,还是不行,我的环境是这样的:
我用的是wampserver 2.2,apache 2.2.21,php 5.3.8 ts,mysql 5.5.16

我的配置过程是:
在c:\下建立了freetds.conf,内容如下:
[global]
tds version = 8.0
client charset = UTF-8
;text size = 20971520
text size = 64512
dump file = c:\FreeTDS.log
debug flags = 0xffff
我将php_dblib.dll拷贝到php的ext下,同时注释了php_mssql.dll重启了apache

phpinfo()内容如下:

mssql

MSSQL Support enabled
Active Persistent Links 0
Active Links 0
Library version FreeTDS

Directive Local Value Master Value
mssql.allow_persistent On On
mssql.batchsize 0 0
mssql.charset UTF-8 UTF-8
mssql.compatability_mode Off Off
mssql.connect_timeout 5 5
mssql.datetimeconvert On On
mssql.max_links Unlimited Unlimited
mssql.max_persistent Unlimited Unlimited
mssql.max_procs Unlimited Unlimited
mssql.min_error_severity 10 10
mssql.min_message_severity 10 10
mssql.secure_connection Off Off
mssql.textlimit Server default Server default
mssql.textsize Server default Server default
mssql.timeout 60 60

测试连接的php代码如下:

<?php
ini_set('display_errors','on');
error_reporting(E_ALL);
header('Content-Type:text/html;charset=utf8');
$link = mssql_connect('192.168.18.100:1433','sa','sa');
mssql_select_db('test');
$sql = "select * from [dbo].[mess]";
//$sql = "insert into [dbo].[mess] values(3,'你好!')";
$res = mssql_query($sql);
while($data = mssql_fetch_assoc($res)){
print_r($data);
//print iconv('','UTF-8',$data['name']);
}
mssql_close();

发现乱码,我又用了插入语句测试,在数据库中显示正常,
但是用以上php代码读取就是乱码,真是奇怪,
我在linux机器上配置了freetds,访问sqlserver却是正常的

请各位朋友帮我看下,还哪里有问题,需要如何配置?

 
評比平均分數: -