Home > database >  Linux PHP can't write in Chinese to the Oracle database
Linux PHP can't write in Chinese to the Oracle database

Time:09-21

Such as: Linux PHP can't write in Chinese to the Oracle database

-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
native environment: Debian 9.5 + Nginx 1.15 2 + PHP 5.6.37 (with PDO_OCI)

Have added the related parameters in the/etc/profile:

Export ORACLE_HOME=/opt/oracle/instantclient
The export PATH=$ORACLE_HOME: $PATH
Export TNS_ADMIN=$ORACLE_HOME/network/admin
# export LD_LIBRARY_PATH=$ORACLE_HOME: $LD_LIBRARY_PATH
Export LD_LIBRARY_PATH=$ORACLE_HOME/lib
Export NLS_LANG="SIMPLIFIED CHINESE_CHINA. AL32UTF8"
-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --

Oracle server : select userenv (" LANGUAGE ") From Dual

SIMPLIFIED CHINESE_CHINA. AL32UTF8


-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
web page code> :
. This code is to define the TNS connect to the database details...
Try {
$conn=new PDO (" oci: dbname=". $tns99, $db_username, $db_password);//note that TNS 90 is to test database
$conn - & gt; The setAttribute (PDO: : ATTR_ERRMODE, PDO: : ERRMODE_EXCEPTION);
//$conn - & gt; (" set names UTF8 ");
{} the catch (PDOException $err)
Echo "database connection fails:". "& lt; Br/& gt;
exit;
}

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +

Question: just can't write Chinese in the database, English writing database isn't any problem,

After another: manually by adding the Chinese PL/SQL, reading to all the Chinese are from the native display garbled,,
  • Related