How to set UTF8 on PHP when connect to ACCESS 2007

2019-07-20 11:01发布

I have Thai,Japan,Korea Character (3 Fields) in Access file.

I created a script in PHP to connect to this file

but character on display is shown ??????? ??????? and ??????

What to SET to show normal character

This is my script

<html>
<head>
<title>TEST</title>
</head>
<body>
<?
$objConnect = odbc_connect("test","","") or die("Error Connect to Database");
$strSQL = "SELECT * FROM table1";
$objExec = odbc_exec($objConnect, $strSQL) or die ("Error Execute [".$strSQL."]");
?>
<table width="600" border="1">
  <tr>
    <th width="20"> <div align="center">ID </div></th>
    <th width="30"> <div align="center">Thai </div></th>
    <th width="30"> <div align="center">Korea </div></th>
     <th width="30"> <div align="center">Japan </div></th>

  </tr>
<?
while($objResult = odbc_fetch_array($objExec))
{
?>
  <tr>
    <td><?=$objResult["ID"];?></div></td>
    <td><?=$objResult["Thai"];?></td>
    <td><?=$objResult["Korea"];?></td>
    <td><?=$objResult["Japan"];?></div></td>
  </tr>
<?
}
?>
</table>
<?
odbc_close($objConnect);
?>
</body>
</html>

1条回答
欢心
2楼-- · 2019-07-20 11:40
 <?
  header('Content-Type: text/html;charset=utf-8');
 ?>

<html>
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <title>TEST</title>
</head>
<title>TEST</title>

<body>

<?
$objConnect = odbc_connect("test","","") or die("Error Connect to Database");
odbc_exec($objConnect, "SET NAMES 'UTF8'");
odbc_exec($objConnect, "SET client_encoding='UTF-8'");

...

Or try in line :

<td><?=mb_convert_encoding($objResult["Japan"], "SJIS");?></td>
查看更多
登录 后发表回答