For the Key Tracker project, we used the Web Server Development Suite for a Windows development environment (a.k.a. "the WAMP stack").

Here are the steps it took to make PHP speak to Oracle on Windows.

0. This WAMP came with PHP compiled with the Oracle option, and with the dlls in the extension library. If your PHP came from somewhere else, consult http://php.net:PHP.net or <U>Programming PHP</U> by Lerdorf and Tatroe for more information.

1. Make a test script so you'll know when it works.

<?php

  if( $db = oci_connect('oracle_login', 'oracle_pwd', 'entry name from tnsnames.ora'))
  {
    echo "Success!";
    oci_close($db);
  } else {
    echo "Failure, could not connect.";
  }

?>

Save as test_connect.php .  Run it from the command line; notice it gives an error.
2. Enable Oracle extension in PHP.
Open php.ini in an editor. In the windows extensions section, uncomment
extension=php_oci8.dll
and save your changes. Notice that this dll is already present in the WAMP stack in the /php5/extensions directory.

3. Install the Oracle client.
The Oracle client may be downloaded from the Supported Windows Software page. Add your connection info to tnsnames.ora if it isn't already there.

Confirm that you can connect with sqlplus, the Oracle query tool that comes with the client.

Many pages say one can install the Oracle Instant Client. This doesn't come with a tnsnames.ora file, and I couldn't find examples of connecting without a tnsnames.ora file. You may wish to take this path, but this HOWTO assumes you've installed the normal Oracle client.

4.  Set ORACLE_HOME .

The symptom for an incorrect or missing ORACLE_HOME is an error that it couldn't locate the network service for this SID. 

In Control Panel > System > Advanced , click the Environment Variables button.  Create a new system variable called ORACLE_HOME and set it to the directory the Oracle client was installed in.  This is most likely c:\Program Files\ora92 .

Edit the PATH system variable and add %ORACLE_HOME% before any other Oracle-related directories.

OK out of the Control Panel. 

If you had a command line window open already, it will  not pick up the change automatically.  You must open a new command window or repeat these settings manuall on the command line.

We did not need to set LD_LIBRARY_PATH, the other common Oracle variable.  

5.  Test.

In some environments, everything will work at this point. We did not find it to be the case with this WAMP stack and our Windows XP installations. Run test_connection.php . You may run it from a web browser, if the test script is in webroot, but error messages are written to apache's error.log  .  Running from the command line gives more informative errors.

At this point in our trek, we got error messages that the dll could not be loaded, and popups that certain DLLs were missing.

6. Add missing DLLs.

Using a dll dependency checker, like depends.exe , inspect php_oci8.dll  . Depends told us we were missing MSVCR71.DLL  and MSJAVA.DLL .  Download missing DLLs from a trusted site and follow installation instructions . ( Our instructions said to add them to C:\WINDOWS\SYSTEM32 .

7. Delete useless NLS_LANG registry key.

If you run the test script now, you'll get an error message about "Missing or unknown NLS entry". NLS_LANG tells Oracle what language to default to. The installed value doesn't correspond to any known language packs.   Per a bug report on the Oracle site,  run regedit.exe and rename or delete the registry key
My Computer\HKEY_LOCAL_MACHINE\SOFTWARE\ORACLE\NLS_LANG .

Alternately, work with an Oracle DBA to give it a meaningful value. 

8. Run the test script.

Voila! At this point, it worked.

OTHER STEPS THAT MIGHT HAVE BEEN HELPFUL:

We tried out a couple of other google-suggested solutions. They may have contributed to solving it, but there was no clear change in behavior.

* Reinstall the php_oci8.dll .

One poster suggested the extension had been improperly compiled . We downloaded the dll from [the PECL repository| http://pecl4win.php.net/ext.php\]  . Since this is part of PHP.net, the home of PHP, it is a trustworthy site.

* Change permissions on the dll and extension driver.

Another poster suggested that permissions were an issue, and their problem was resolved by giving full control on the extensions directory to Everybody from the file explorer.  

RESOURCES

[PHP.net|http://php.net] is your friend, especially the [manual section on OCI8|http://php.net/manual/en/ref.oci8.php].

The Oracle site hosts [The Underground PHP and Oracle Manual|http://www.oracle.com/technology/tech/php/pdf/underground-php-oracle-manual.pdf] .

If you are developing your own application, rather than configuring an existing PHP and Oracle application, it's well to use the [PEAR::MDB2 package|http://pear.php.net/package/MDB2].  This will give you portability between database flavors.