php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #5452 Problem about php and oracle with chinese text
Submitted: 2000-07-08 10:15 UTC Modified: 2006-07-17 08:41 UTC
From: inetwolf at at 63 dot net Assigned:
Status: Not a bug Package: OCI8 related
PHP Version: 4.0.1pl2 OS: solaris 2.6
Private report: No CVE-ID: None
View Add Comment Developer Edit
Anyone can comment on a bug. Have a simpler test case? Does it work for you on a different platform? Let us know!
Just going to say 'Me too!'? Don't clutter the database with that please !
Your email address:
MUST BE VALID
Solve the problem:
40 + 6 = ?
Subscribe to this entry?

 
 [2000-07-08 10:15 UTC] inetwolf at at 63 dot net
Sorry,I can't modify the bug id 5341
repost in details

==================================================
Version Affected : both 3.0.16 & 4.0.1 & 4.0.1pl2
Oracle version : 8.1.5
OS : Solaris 2.6 105181-20
WEB server : NES 3.6
NLS_LANG=ZHS16CGB231280


PHP can't work fine with chinese string in the query, both insert and select.It seems that
PHP trunck the 8bit chinese text string to 7bit ascii text.The cgi program  set the
NLS_LANG parametre the sam as db server.
But sqlplus work well.

attention: there are some chinese text,you must have some software that can display it.

source code:
--------------------------------------- 
<?php  
putenv("LD_LIBRARY_PATH=/u01/app/oracle/product/8.1.5/lib"); 
putenv("nls_lang=_china.zhs16cgb231280");  
putenv("ORACLE_BASE=/u01/app/oracle"); 
putenv("ORACLE_HOME=/u01/app/oracle/product/8.1.5"); 
putenv("ORACLE_SID=oracle8"); 
putenv("ORA_NLS33=/u01/app/oracle/product/8.1.5/ocommon/nls/admin/data 
 "); 

$conn = OCILogon("scott","tiger");  
OCIInternalDebug(1); 
$stmt = OCIParse($conn,"insert into emp (empno,ename) values (3,'&#20013;&#25991;&#23383; 
&#20307;')  returning ename into :name");  
OCIBindByName($stmt,":name",&$name,32);  
OCIExecute($stmt);  
while (OCIFetch($stmt)) {  
    echo "ename:".$name."\n<br>";  
}  
OCIFreeStatement($stmt);  
OCILogoff($conn);  
?>  

--------------------------------------- 

error message:
--------------------------------------- 
OCIDebug: oci_parse "insert into emp (empno,ename) values (3,'&#20013;&#25991;&#23383;&#20307; 
') returning ename into :name" id=4 conn=3 

Warning: OCIStmtExecute: ORA-24365: error in character conversion in / 
usr/netscape/suitespot/docs/q.php on line 13 

Warning: OCIFetch: ORA-24374: define not done before fetch or execute  
and fetch in /usr/netscape/suitespot/docs/q.php on line 14 
OCIDebug: START _oci_stmt_list_dtor: id=4 last_query="insert into emp  
(empno,ename) values (3,'&#20013;&#25991;&#23383;&#20307;') returning ename into :name" 
OCIDebug: _oci_bind_hash_dtor: 
OCIDebug: END _oci_stmt_list_dtor: id=4 
OCIDebug: START php_rshutdown_oci 
OCIDebug: END php_rshutdown_oci 
OCIDebug: START _oci_conn_list_dtor: id=3 
OCIDebug: END _oci_conn_list_dtor: id=3 
OCIDebug: _oci_close_session: logging-off sess=2 
OCIDebug: START _oci_close_server: detaching conn=1 dbname= 
---------------------------------------------------------------- 

About the database:
---------------------------------------------------------------- 
$ sqlplus 

SQL*Plus: Release 8.1.5.0.0 - Production on Fri Jul 7 13:15:16 2000 

(c) Copyright 1999 Oracle Corporation.  All rights reserved. 

Enter user-name: scott 
Enter password: 

Connected to: 
Oracle8i Enterprise Edition Release 8.1.5.0.0 - Production 
With the Partitioning and Java options 
PL/SQL Release 8.1.5.0.0 - Production 

SQL> select * from emp; 

     EMPNO ENAME      JOB              MGR HIREDATE         SAL        
COMM 
---------- ---------- --------- ---------- --------- ---------- ------ 
---- 
    DEPTNO 
---------- 
         3 VPNDWVLe 

SQL> insert into emp (empno,ename) values (1,'&#20013;&#25991;&#23383;&#20307;'); 

1 row created. 

SQL> select * from emp; 

     EMPNO ENAME      JOB              MGR HIREDATE         SAL        
COMM 
---------- ---------- --------- ---------- --------- ---------- ------ 
---- 
    DEPTNO 
---------- 
         3 VPNDWVLe 


         1 &#20013;&#25991;&#23383;&#20307; 



SQL>                                                                   
          
---------------------------------------------------------------- 


analysis: 

---------------------------------------------------------------- 
The character set of oracle is simplified chinese,
There is no problem when manipulating database with sqlplus,
The problem is the interface with php and oracle.

$ oerr ora 24365 
24365, 00000, "error in character conversion" 
// *Cause:  This usually occurs during conversion of a multibyte 
//          character data when the source data is abnormally terminat 
ed 
//          in the middle of a multibyte character. 
// *Action: Make sure that all multibyte character data is properly te 
rminated. 
$                                                                      
          
Without the second error message,the first will not display,
but the data it insert into the database is asccii ,too.
---------------------------------------------------------------- 




Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2000-07-09 13:11 UTC] thies at cvs dot php dot net
closed on behalf of reporting user
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Thu Mar 28 12:01:27 2024 UTC