1 2 3 Previous Next 30 Replies Latest reply: May 17, 2008 2:13 PM by cj RSS

    Frustrations - PHP5 to Oracle8i using IIS

    524415
      I know that many people have posted problems with php connections to oracle all over the net. I have read tons of forum postings but none that have solved my problem. I am hoping that someone here can help.

      -I have php installed on a webserver using IIS6. I have it working properly and able to display php pages.
      -I have oracle8i client installed on the webserver and I am able to connect to the database using sqlplus and i am able to perform a tnsping and resolve the db name.
      -I have modified my php.ini file to uncomment the php_oci8.dll and php_oracle.dll and I have tried a multitude of path changes to get the php_oci8.dll to load but nothing has worked. I am unable to connect to the database.
      -I have given permission to the IUSR_[computername] to the oracle directory on the webserver machine, though we do not allow anonymous login, I also have given the webuser account access to the oracle folder as well.


      Here is my simple php connection script:
      <body>
      <?php

      $conn = oci_connect('username', 'password', 'databasename');
      if (!$conn) {
      $e = oci_error();
      print htmlentities($e['message']);
      exit;
      }

      $query = 'SELECT * FROM employee';

      $stid = oci_parse($conn, $query);
      if (!$stid) {
      $e = oci_error($conn);
      print htmlentities($e['message']);
      exit;
      }

      $r = oci_execute($stid, OCI_DEFAULT);
      if (!$r) {
      $e = oci_error($stid);
      echo htmlentities($e['message']);
      exit;
      }

      print '<table border="1">';
      while ($row = oci_fetch_array($stid, OCI_RETURN_NULLS)) {
      print '<tr>';
      foreach ($row as $item) {
      print '<td>'.($item?htmlentities($item):' ').'</td>';
      }
      print '</tr>';
      }
      print '</table>';

      oci_close($conn);
      ?>

      </body>

      HERE IS THE ERROR I GET
      Fatal error: Call to undefined function oci_connect() in C:\Inetpub\wwwroot\site\phpscript\BASICdb.php on line 10
      PHP Warning: PHP Startup: Unable to load dynamic library 'C:\PHP\ext\php_oci8.dll' - The specified procedure could not be found. in Unknown on line 0 PHP Warning: PHP Startup: Unable to load dynamic library 'C:\PHP\ext\php_oracle.dll' - The specified module could not be found. in Unknown on line 0

      There is obviously something wrong since the function oci_connect isnt found. I have tried registering the dll, but that doesnt work. I have tried a variety of settings for the ext path, but none of them have helped.

      Any ideas??
        • 1. Re: Frustrations - PHP5 to Oracle8i using IIS
          392393
          Does the webuser account have access to the php extensions folder? It looks like it isn't even finding the dll file...

          ~Jer
          • 2. Re: Frustrations - PHP5 to Oracle8i using IIS
            524415
            Yes, the iuser account does have permissions to that directory. My first thought was the php_oci8.dll error meant that php could not find the file, so that is when I took a chance and tried to regsvr32 it, but that errored out. So I guess it isnt meant to be registered. I also reinstalled php, thinking the first install did not complete properly. I have verified that all the dll's are in that ext folder. (hence, the frustration.)
            • 3. Re: Frustrations - PHP5 to Oracle8i using IIS
              524415
              I did not notice this before, but at the bottom of my phpinfo() page I also get this error message.

              PHP Warning: PHP Startup: Unable to load dynamic library 'C:\PHP\ext\php_oci8.dll' - The specified procedure could not be found. in Unknown on line 0

              Do I need to reinstall the oracle 8i client? Do I need to download any additional DLL files. It seems that even though the file is located in the ext directory, it is either invalid or corrput.

              I have downloaded other versions of the php_oci8 file, but nothing has worked yet.

              I know someone out there has a great solution....
              • 4. Re: Frustrations - PHP5 to Oracle8i using IIS
                392393
                I've never seen the error, but I don't use IIS either. Apache is just easier :)
                • 5. Re: Frustrations - PHP5 to Oracle8i using IIS
                  524415
                  I agree that apache may be easier, but we 'need' to use IIS.

                  So, I am doing more digging and it seems that you have to 'install'
                  oracle dlls that are not bundled with the php5 distribution. I assumed since I have the oracle8i client installed and can connect using tnsping and sqlplus, I would have the necessary dll's registered on the system. Do I need to copy some dll's to my php\ext folder?

                  I cannot seem to get the php_oci8.dll to be recognized by php.......
                  • 6. Re: Frustrations - PHP5 to Oracle8i using IIS
                    392393
                    You shouldn't, no. But try setting ORACLE_HOME in an environment variable and see if that works.

                    ~Jer
                    • 7. Re: Frustrations - PHP5 to Oracle8i using IIS
                      524415
                      Nope. I set the env. variable to the oracle directory, restarted and still getting the error.
                      • 8. Re: Frustrations - PHP5 to Oracle8i using IIS
                        392393
                        Have you tried using the PECL extensions instead of the distribution ones? I assumed you had based on previous posts, but maybe my assumptions aren't correct.
                        http://www.php.net/get/pecl-5.1.4-Win32.zip/from/a/mirror
                        • 9. Re: Frustrations - PHP5 to Oracle8i using IIS
                          524415
                          OK, we are getting closer. I did not download that package, I noticed that the php_oci8.dll was not included in that package, so I just uncommented the php_oracle.dll in the php.ini file. I now have an oracle header on the phpinfo page and it is enabled. However, when I go to the webpage I get an error

                          Fatal error: Call to undefined function ocilogon() in c:\Inetpub\wwwroot\site\phpscript\BASICdb.php on line 11

                          So seeing that, I tried uncommenting the php_oci8.dll file, but that only cause an error on both the phpinfo page and the database connection page. So I am wondering if I have a bad php_oci8 file. Or, do I have something else configured wrong. Better yet, do I need to download any additional files.
                          • 10. Re: Frustrations - PHP5 to Oracle8i using IIS
                            392393
                            That's why I said to grab the PECL files for Windows. There should be a php_oci8.dll in the PECL zip.

                            ~Jer
                            • 11. Re: Frustrations - PHP5 to Oracle8i using IIS
                              524415
                              Jer-

                              I thought there would be also, however, there is not one. They did have the php_oracle.dll in there, so I tried commenting that dll extension, but the ocilogon and oci_connect functions are not in that library.

                              Any thoughts

                              -Bryan
                              • 12. Re: Frustrations - PHP5 to Oracle8i using IIS
                                524415
                                I just tried reinstalling the Oracle 8i client....Just to eliminate that as a possible solution.....It did not resolve any issues.

                                It is strange thought, when I reboot the server, the Oracle web db listener does not allow IIS to start the web site because it has a handle on a file. As a work around I have been shutting down the web db listener, then starting iis websites, then restarting web db listener.

                                I dont know if that has any ties to the other issues I am having being unable to load the oci8.dll file, but I just thought maybe this little tidbit would help resolving this problem....?
                                • 13. Re: Frustrations - PHP5 to Oracle8i using IIS
                                  392393
                                  It's in the pecl-5.1.2-Win32.zip but not pecl-5.1.4-Win32.zip, isn't that odd?

                                  http://pecl4win.php.net/list.php
                                  http://pecl4win.php.net/ext.php/php_oci8.dll

                                  You might be able to use the 5.1.2 version with 5.1.4 but I'd downgrade to 5.1.2...
                                  • 14. Re: Frustrations - PHP5 to Oracle8i using IIS
                                    524415
                                    Well, I downloaded the PECL 5.1.2, but that didnt solve it.

                                    I notice that when I open php-cgi.exe, I get an 'Entry Point Not Found' error
                                    "The procedure entry point OCIStmtPrepare2 could not be located in the Dynamic Link Library OCI.dll"

                                    I also noticed that when I comment the php_oci8.dll out, the error goes away and the php command prompt executes. Also note that the php_oracle.dll is still uncommented.

                                    I am wondering if my oci.dll does not have a function call that the php_oci8.dll is needing. I wonder if I need to keep downgrading the php_oci8.dll file?

                                    Any thoughts?
                                    1 2 3 Previous Next