5 Replies Latest reply: May 2, 2006 8:39 AM by 508651 RSS

    Problems with connection from PHP to Oracle DB


      I have a Win2k3 Server with IIS 6.0 and PHP 5.1.2. and an Oracle Client 9i installed.

      Recently I tried to connect via PHP to the DB but it failed with the following message:
      "Warning: ocilogon() [function.ocilogon]: OCIEnvInit() failed. There is something wrong with your system - please check that ORACLE_HOME is set and points to the right directory in ...\php-skript\test\funk_test.php on line 54"

      So I started looking in the internet for help and found a lot, but nothing that solved my problem. I tried everything (I think):
      * Oracle Client 9i regular Client- environment vars in all variations
      * Oracle Client 10g Instant Client- all variations again
      * I tried to delete all spaces in the "tns.ora" after a hint in another PHP-forum
      * I looked in this forum and found some hints

      BUT: Nothing helped me to solve my problem.

      So I changed my PHP-version from 5.1.2 to 5.0.4 and I got a different failure:
      "[26-Apr-2006 17:58:15] PHP Warning: ocilogon() [<a href='function.ocilogon'>function.ocilogon</a>]: _oci_open_server: ˜Õ‚ in ...\php-skript\test\funk_test.php on line 56"

      This message is really strange, because it contains no information about the failure.

      Has ANYONE another hint for me?? I really don't know what I should do.
        • 1. Re: Problems with connection from PHP to Oracle DB
          There's little IIS and Oracle info on the web; when you have solved your problem please post a clear solution.

          How exactly did you try to set the Oracle environment variables.

          There is some information in Access denied on php_oci8.dll and php_oracle.dll

          I've also seen hints to make sure oracle\bin is in $_ENV['PATH']. You probably need to reboot if you change any environment to make sure IIS inherits the changes.

          -- cj
          • 2. Re: Problems with connection from PHP to Oracle DB
            Because it's IIS, I set the env vars manually. That means --> my computer/.../advanced/environment vars/etc.

            After every change, I rebootet the IIS Service. Problem consists.

            Let's have a look, if your links could help...

            ########## EDIT ##########
            Ok, your links WERE INDEED REALLY helpful!
            My problems were caused by missing access-rights.

            How to solve this problem:
            * reinstall your Oracle-client
            * inet-user needs now access rights for
            + "oracle"- folder
            + "oracle\bin"- folder
            + "tnsnames.ora"- file
            * set environment vars
            + NLS_LANG = AMERICAN
            + ORACLE_HOME = "C:\oracle\ora92"
            + TNS_ADMIN = "C:\oracle\ora92\network\ADMIN"
            * restart IIS

            Now it should work!!! THX for your help!
            • 3. Re: Problems with connection from PHP to Oracle DB
              Thanks for the summary.

              For the record, one of the directories Oracle looks in for tnsnames.ora is ORACLE_HOME\network\admin. So TNS_ADMIN doesn't need to be set unless you are using another location for tnsnames.ora.
              • 4. Re: Problems with connection from PHP to Oracle DB
                To make it easier for the next person, I wrote up your solution and posted it on http://blogs.oracle.com/opal/#a24

                I should have mentioned that because you are using PHP 5.1.2 on Windows, you should pull the latest php_oci8.dll from http://pecl4win.php.net/ext.php/php_oci8.dll to avoid a threading bug.
                • 5. Re: Problems with connection from PHP to Oracle DB
                  Thanks for the link. I'll replace the dll immediately.