PHP & Oracle - oci_connect() ORA-12705: Cannot access NLS data files
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:
- Do you have Oracle Instant Client? If not get it.
- Do you have the Oracle SDK? If not get it.
- Unzip instantclient.
- Unzip the SDK into a sub-directory
- 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.
- Create ORACLE_BIN and have it point to the SDK.
- Add ORACLE_HOME to your PATH.
- 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.
Related videos on Youtube
Nick
Updated on June 01, 2022Comments
-
Nick almost 2 years
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
-
Pekka almost 13 yearsHave you restarted the web server? Are you 100% sure you're editing the right php.ini as mentioned when calling
phpinfo()
? -
Pekka almost 13 yearsDoes
phpinfo()
make any mention of OCI? -
Pekka almost 13 yearsHmm, then the extension isn't getting loaded. Which should mean that it's not reading the
extension=php_oci8_dll
line, otherwise it would crash on restart. But you say you've checked the paths, and it's the correct php.ini... Weird! -
Pekka almost 13 yearsfrom my experience, it either manages to successfully read the extension file, or it crashes. There is no grey area there. What you could try to do is deliberately change the file name to something incorrect. If that goes through without complaint, it's not reading the INI file for whatever reason
-
dqhendricks almost 13 years
-
-
Nick almost 13 yearsHuge thanks for this! It's now loading the PHP files but says: Warning: oci_connect() [function.oci-connect]: ORA-12705: Cannot access NLS data files or invalid environment
-
cwallenpoole almost 13 years:::sigh::: Well, at that point, I just downloaded everything in at the Oracle Instant Client SDK site and put it all into one sub-directory. If that doesn't work, let me know and tomorrow I'll look into the TNSADMIN stuff.
-
Nick almost 13 yearsThank you, but which is the Instant Client SDK download? oracle.com/technetwork/database/features/instant-client/… In the end I used the JRE from here, but it's probably wrong: oracle.com/technetwork/java/javase/downloads/index.html Thanks again!
-
cwallenpoole almost 13 yearsInstantclient is here: oracle.com/technetwork/database/features/instant-client/… You'll need to figure out which one on your own though -- it's hardware architecture specific.
-
Nick almost 13 yearsThank you! Lots of faffing around and ifnally got it working - lots of playing with the registry, the environmental variables paths, the tns_admin, oracle_home and all manner of other things, wooooo! thanks again :)