PHP & Oracle - oci_connect() ORA-12705: Cannot access NLS data files

余生长醉 提交于 2019-12-22 17:29:13

问题


We've been using Oracle on our server for years, but someone from IT removed it yesterday without clear warning and it's really thrown our systems!

I've acted on the advice from cwallenpoole (thank you!) and have made good progress, and PHP is now at least including the oracle functions (ie oci_connect) but I am now experiencing another error message:

"Warning: oci_connect() [function.oci-connect]: ORA-12705: Cannot access NLS data files or invalid environment"

We have ensured the tnsnames.ora etc files are in the correct place, but still having no joy :(

thank you


回答1:


Ok. This is my personal nightmare. I seriously wake up in the middle of the night... or I don't, but I have spent days on this problem.

So, this is what worked for me:

  1. Do you have Oracle Instant Client? If not get it.
  2. Do you have the Oracle SDK? If not get it.
  3. Unzip instantclient.
  4. Unzip the SDK into a sub-directory
  5. Add ORACLE_HOME as an exported command line variable ($ORACLE_HOME in *nix, %ORACLE_HOME% in win). Have it point to the fully-qualified path to the above instantclient folder.
  6. Create ORACLE_BIN and have it point to the SDK.
  7. Add ORACLE_HOME to your PATH.
  8. Restart Apache...

So... that is what I generally do... And generally it works... Mostly...

I think that realistically all I can say is Good Luck and Godspeed.




回答2:


The only way I could get PHP to connect to Oracle was using the Zend Framework.

http://framework.zend.com/




回答3:


Follow this procedure to set the NLS_LANG environment variable for Oracle databases. To set the NLS_LANG environment variable for Oracle databases Determine the NLS_LANG value. In the data warehouse database, run the command

SELECT * FROM V$NLS_PARAMETERS

Make a note of the NLS_LANG value, which is in the format [NLS_LANGUAGE]_[NLS_TERRITORY].[NLS_CHARACTERSET]. For example: American_America.UTF8

For Windows: Navigate to Control Panel > System and click the Advanced tab. Click Environment Variables.

In System variables section, click New. In the Variable Name field, enter NLS_LANG. In the Variable Value field, enter the NLS_LANG value that was returned in Step 1. The format for the NLS_LANG value should be [NLS_LANGUAGE]_[NLS_TERRITORY].[NLS_CHARACTERSET]. For example: American_America.UTF8. For UNIX, set the variable as shown below: setenv NLS_LANG

For example: setenv NLS_LANG American_America.UTF8. If your data is 7-bit or 8-bit ASCII and the Informatica Server is running on UNIX, then set NLS_LANG _.WE8ISO8859P1 CAUTION: Make sure you set the NLS_LANG variable correctly, as stated in this procedure, or your data will not display correctly.

Reboot the machine after creating the variable.



来源:https://stackoverflow.com/questions/6549251/php-oracle-oci-connect-ora-12705-cannot-access-nls-data-files

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!