无法在mysql中显示php中的utf-8数据

时间:2014-01-29 10:55:12

标签: php mysql utf-8 utf8-decode

嗨我有数据存储在mysql服务器的hindi中,我无法显示它输出这里是我的代码

<?php
//string utf8_decode(string $product);
/*mysql_query('SET character_set_results=utf8');
mysql_query('SET names=utf8');
mysql_query('SET character_set_client=utf8');
mysql_query('SET character_set_connection=utf8');
mysql_query('SET character_set_results=utf8');
mysql_query('SET collation_connection=utf8_general_ci');*/
header( 'Content-Type: text/html; charset=utf-8' ); 


// array for JSON response
$response = array();



require_once __DIR__ . '/db_connect.php';

// connecting to db
$db = new DB_CONNECT();


$result = mysql_query("SELECT *FROM create_event") or die(mysql_error());


if (mysql_num_rows($result) > 0) {
    // looping through all results
    // products node
    $response["create_event"] = array();

    while ($row = mysql_fetch_array($result)) {
        // temp user array
        $product = array();
        $product["eventid"] = $row["eventid"];
        $product["description"] = $row["description"];
        $product["title"] = $row["title"];
        $product["startdate"] = $row["startdate"];
        $product["enddate"] = $row["enddate"];




        // push single product into final response array
        array_push($response["create_event"], $product);
    }
    // success
    $response["success"] = 1;

    // echoing JSON response
    echo json_encode($response, JSON_HEX_TAG | JSON_HEX_APOS | JSON_HEX_QUOT |  JSON_HEX_AMP | JSON_UNESCAPED_UNICODE);
} else {
    // no products found
    $response["success"] = 0;
    $response["message"] = "No products found";

    // echo no users JSON
    echo json_encode($response, JSON_HEX_TAG | JSON_HEX_APOS | JSON_HEX_QUOT |      JSON_HEX_AMP | JSON_UNESCAPED_UNICODE);
}
?>

数据以mysf服务器的utf8_unicode_ci格式存储 这是我从浏览器中的PHP代码获得的输出

{"create_event":     

[{"eventid":"1","description":"????????","title":"?????","startdate":"5-12-12","enddate":"5-12-45"}],"success":1}

值为???????? k的数据是存储在hindi中的数据.Kindly,帮助我,因为我是php的新手。
感谢!!!

1 个答案:

答案 0 :(得分:-1)

http://rafeekphp.wordpress.com/2009/06/10/multi-language-support-in-mysql/

  

如果结果显示像????然后在您的系统中(Windows XP)需要通过启用以下选项来安装语言支持工具,

     

控制面板 - &gt;区域和语言选项 - &gt;语言 - &gt;安装复杂脚本和从右到左语言(包括泰语)的文件