I believe that by the time of execution this will not work, this because when it executes the putenv
the Oracle client is already running, and if I am not mistaken, the communication of PHP with the Oracle client is "parallel" and not in the same "context", ie use putenv
will not affect the oracle client process.
What you can do is add manually, in windows do this:
Computer > Estates > Advanced system settings
A window similar to this will appear:
Then click on Environment variables and then in New..., thus:
If using the oracle client on more than one user use variaveis de sistema
(is preferred), if using only on the current user and you really want to restrict to this then select the "new" from the "User variables to ".
In the variable name field add NLS_LANG
In the variable value field add BRAZILIAN PORTUGUESE_BRAZIL.WE8MSWIN1252
After this you may need to log out or even restart Windows.
Using Apache and PHP
Note that apply NLS_LANG=BRAZILIAN PORTUGUESE_BRAZIL.WE8MSWIN1252
will only affect the oracle client, this will not affect the PHP database Apis or Apache, because the apache charset as well as the INPUT coming from Forms or even how you saved the scripts .php
may be in a different encoding.
The BRAZILIAN PORTUGUESE_BRAZIL.WE8MSWIN1252
is equivalent to windows-1252, which is equivalent to iso-8859-1, and as I explained in this reply /a/43205/3635 you must use:
- PHP scripts saved in "iso-8859-1" (or windows-1252 and ANSI)
- Preferably define using PHP
header('Content-type: text/html; charset=iso-8859-1');
First you must save "all . php scripts" as iso-8859-1 (or ANSI) and . html documents (if any):
Note: I believe that is not necessary define in the oci_connect
the charset, as it already assumes the charset defined in NSLANG
, but chance doesn’t work try so:
$db = ocilogon($user, $pass, $connectString, 'WE8MSWIN1252');