【问题标题】:Displaying Hindi data stored in MS Access Database in PHP/HTML以 PHP/HTML 显示存储在 MS Access 数据库中的印地语数据
【发布时间】:2013-06-09 06:06:04
【问题描述】:

网络上有很多关于从数据库中以 PHP/HTML 显示印地语文本的帮助,但没有一个对我有用。

我将数据存储在 MS Access [SAP.mdb] 中,我希望数据 [已经在 db 中的印地语中] 以 PHP 中的印地语显示。

我尝试过的代码如下所示。我已经应用了所有可能的解决方案,但我得到的只是??????????

<! DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" 
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
  <body>
  <meta http-equiv="Content-Language" content="hi">
  <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
  <label>
    <form id="form1" name="form1" method="get" action="trial10.php">
      SAP ID<input type="text" name="textfield" default="ff"/>
      <?php
        header( 'Content-Type: text/html; charset=utf-8' );
        $conn = odbc_connect("manish", "","");
        echo $conn;
        $sql="SELECT * FROM SAP";
        $rs=odbc_exec($conn,$sql);
        echo $rs;
        odbc_fetch_row($rs);
        echo odbc_result($rs,3);
      ?>
    </label>
  </body>
</html>

【问题讨论】:

    标签: php html unicode utf-8 hindi


    【解决方案1】:

    您在从数据库中检索数据的方式或将其发送到浏览器的方式中都会出错。

    要找出请将此代码放在您要回显数据的位置:

    $result = odbc_result($rs,3);
    $resultInHex = unpack('H*', $result);
    $resultInHex = $resultInHex[1];
    $resultSeparated = implode(', ', str_split($resultInHex, 2)); //byte safe
    
    var_dump($resultSeparated);
    

    这将分割从数据库中检索到的字节并显示它们的原始值。也就是说,您将能够查看是否已检索到正确的字节,或者 PHP 和数据库之间是否发生错误。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2012-09-08
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多