PHP Operation Oracle Query when the Chinese garbled, how to handle

Source: Internet
Author: User
Tags sqlplus
PHP Operation Oracle Query when Chinese garbled
Environment:
The Oracle database is installed on XP.
Version: 10.2.0.3
Nls_language
AMERICAN

Nls_territory
AMERICA

Nls_characterset
Zhs16gbk

One, Sqlplus client operation database (client operation locale is simplified Chinese_china. ZHS16GBK):
1.
Cmd
Set NLS_LANG=AMERICAN_AMERICA.ZHS16GBK
Sqlplus/nolog
conn [email protected]
INSERT into EMP values (' 7777 ', ' You ', ' good ', ' 7709 ', ' January-November-2012 ', ' 5000 ', ' 800 ', ' 20 ');
Commit
SELECT * from EMP;

EMPNO ename JOB MGR hiredate SAL COMM
---------- ---------- --------- ---------- ------------ ---------- ----------
DEPTNO
----------
7777 Hello 7709 01-nov-12 5000 800
20
Conclusion: The database I entered is not a problem.

Second, PHP through the OCI operation Oracle
1, PHP so operation and Environment for Windows 2003 x86 Enterprise Edition Simplified Chinese +iis6.0+oracle instantclient-basic-win32-10.2.0.4.zip+fcgisetup_1.5_rtw_ X86.msi
2. After all the necessary environments have been configured, test the
Phpinfo ();
?>
Show everything OK
3. Start operating Oracle


Echo Oci_client_version ();

Header (' content-type:text/html; CHARSET=ZHS16GBK ');
Set NLS_LANG=AMERICAN_AMERICA.ZHS16GBK
Export NLS_LANG=AMERICAN_AMERICA.ZHS16GBK
Putenv ("NLS_LANG=AMERICAN_AMERICA.ZHS16GBK");

$conn = Oci_connect (' Scott ', ' Tiger ', ' 192.168.1.50/salesnew ', ' ZHS16GBK ');
if (! $conn) {
$e = Oci_error ();
Trigger_error (Htmlentities ($e [' message '], ent_quotes), e_user_error);

}
echo oci_server_version ($conn);
Prepare the statement
$stid = Oci_parse ($conn, ' SELECT * from EMP ');
if (! $stid) {
$e = Oci_error ($conn);
Trigger_error (Htmlentities ($e [' message '], ent_quotes), e_user_error);
}

Perform the logic of the query
$r = Oci_execute ($stid);
if (! $r) {
$e = Oci_error ($stid);
Trigger_error (Htmlentities ($e [' message '], ent_quotes), e_user_error);
}

Fetch the results of the query
Print "







\ n "; while ($row = Oci_fetch_array ($stid, oci_assoc+oci_return_nulls)) {print" \ n "; foreach ($row as $item) {print ' \ n "; } print " \ n ";} Print "
" . ($item!== null? htmlentities ($item, ent_quotes): ""). "
\ n ";

Oci_free_statement ($stid);
Oci_close ($conn);
echo "test page itself in Chinese display situation";
?>

Chinese part garbled
As shown below:

10.2.0.4.0Oracle Database 10g Enterprise Edition Release 10.2.0.3.0-production with the partitioning, OLAP and Data Mini NG Options
7777äãºã7709 01-NOV-12 5000 800 20
8888öóº£7709 01-NOV-10 5000 800 20
9999àî¾ê8888 01-jan-11 3000 5000 20
7369 SMITH Clerk 7902 17-dec-80 800 20
7499 ALLEN salesman 7698 20-feb-81 1600 300 30
7521 WARD salesman 7698 22-feb-81 1250 500 30
7566 JONES MANAGER 7839 02-apr-81 2975 20
7654 MARTIN salesman 7698 28-sep-81 1250 1400 30
7698 BLAKE MANAGER 7839 01-may-81 2850 30
7782 CLARK MANAGER 7839 09-jun-81 2450 10
7788 SCOTT ANALYST 7566 19-apr-87 3000 20
7839 KING President 17-nov-81 5000 10
7844 TURNER salesman 7698 08-sep-81 1500 0 30
7876 ADAMS Clerk 7788 23-may-87 1100 20
7900 JAMES Clerk 7698 03-dec-81 950 30
7902 FORD ANALYST 7566 03-dec-81 3000 20
7934 MILLER Clerk 7782 23-jan-82 1300 10
Test the display of the page itself in Chinese


This problem has been tossing me crazy, Baidu, Google for several days can not solve the problem.
Tried the following methods
1. Set the operating system environment variable nls_lagn=simplified chinese_china that the PHP environment is located in. ZHS16GBK or NLS_LANG=AMERICAN_AMERICA.ZHS16GBK.
  • Related Article

    Contact Us

    The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

    If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.