?php
$link = mssql_pconnect("192.168.0.18", "sa", "123") or die("Could not connect");
mssql_select_db("ng0001") or die("Could not select database");
$sql = "SELECT appeId,survId,location,surveyDate,surveyTime,inputUserId FROM aaa ";
$rs = mssql_query($sql);
while($obj = mssql_fetch_object($rs))
{
        
        $arr[] = $obj;
    
}
$json_string = json_encode($arr);
echo $json_string?>
我的代码是这样写的,数据是英文没有问题,能帮我看看怎么改才能让select查询出的中文数据显示出来!!!而不是空值

解决方案 »

  1.   

    <?php
    header("Content-Type:text/html;charset=utf-8");
    $link = mssql_pconnect("192.168.0.18", "sa", "123") or die("Could not connect");
    mssql_select_db("ng0001") or die("Could not select database");
    $sql = "SELECT appeId,survId,location,surveyDate,surveyTime,inputUserId FROM aaa ";
    $rs = mssql_query($sql);
    while($obj = mssql_fetch_object($rs))
    {

    $arr[] = $obj;
        
    }
      $json_string = json_encode($arr);
     echo $json_string 
    ?>
    页面编码是utf-8,字段都是char类型
      

  2.   

    字符集和编码要一样的,要不就显示不完整,前面加上mysql_query("set names gbk") 红的好像要和字符集一样,我也不大肯定,试试看吧,
      

  3.   

    我这个是 sqlserver2000,不是mysql
      

  4.   

    楼主的字段类型设置为nchar类型试试