Skip to Main Content

Database Software

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Oracle and PHP - insert special characters problem

487772Feb 2 2006 — edited Mar 18 2006
I have computer with these software:
Fedora Core 4
Apache 2.0.54
PHP 5.0.4
Oracle 10.2.0
Firefox (character set: UTF8)


System environment:
[oracle@computer /] echo $ORACLE_HOME
/db/u01/app/oracle/product/10.2.0/db_1
[oracle@computer /] echo $NLS_LANG
SLOVENIAN_SLOVENIA.AL32UTF8
I get this for every user, because I have in /etc/profiles:
NLS_LANG=SLOVENIAN_SLOVENIA.AL32UTF8; export NLS_LANG;
ORACLE_HOME=/db/u01/app/oracle/product/10.2.0/db_1; export ORACLE_HOME;
...


Oracle NLS parameters:
SQL> SELECT NLS_LANGUAGE, NLS_TERRITORY, NLS_CHARACTERSET FROM NLS_DATABASE_PARAMETERS;
SLOVENIAN, SLOVENIA, AL32UTF8

And similar for NLS_INSTANCE_PARAMETERS and NLS_SESSION_PARAMETERS.


phpinfo() returns:
...
Apache Environment
Variable Value
NLS_LANG SLOVENIAN_SLOVENIA.AL32UTF8
...


In /etc/php.ini I have:
default_charset = "UTF-8"
mbstring.internal_encoding = UTF-8

In /etc/httpd/conf/httpd.conf:
SetEnv NLS_LANG SLOVENIAN_SLOVENIA.AL32UTF8

In my PHP script "oracle.php" (file encoding is UTF-8) I have:
...
<meta http-equiv="Content-Type" content="text/html;charset=UTF-8" >
...
putenv("NLS_LANG=SLOVENIAN_SLOVENIA.AL32UTF8");
...
And then code similar to Example 2 in: http://www.php.net/manual/en/ref.oci8.php


Problem
When I am trying with PHP insert character "š" ( http://www.fileformat.info/info/unicode/char/0161/index.htm ) or some other special character into Oracle table and then do SELECT from this table I get value "??" which is wrong.

There is no problem for example with char "a". There is no problem inserting data with SQLPlus or Toad for Oracle - inserted data is always correct. There is no problem for example with echo("some_special_sharacters"); in PHP. I have no problems inserting data with PHP to MySQL database.

I have read this, but problem still exists:
http://www.oracle.com/technology/tech/php/pdf/globalizing_oracle_php_applications.pdf

Plese help.

Thanks!
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Apr 15 2006
Added on Feb 2 2006
1 comment
5,966 views