1

I followed the steps to download oracle instant client and add it to PATH, add php extensions and enable it in php.ini. The basic information listed as follows:

  • OS: Windows 10 Enterprise x64
  • PHP: 7.3.30 (cli) (built: Aug 25 2021 09:48:17) ( ZTS MSVC15 (Visual C++ 2017) x64 )
  • Oracle instant client: instantclient-basic-windows.x64-12.1.0.2.0
  • php extension for oracle database: php_oci8-2.2.0-7.3-ts-vc15-x64

After all configuration done, I test the oracle connection with following code:

$conn = oci_connect("testuser", "testpassword", "testtns;
if (!$conn) {
    $m = oci_error();
    echo $m['message'], "\n";
    exit;
}
else {
print "Connected to Oracle!";
}
// Close the Oracle connection
oci_close($conn);

The web page shows positive result: Connected to Oracle!

Then the problem comes: When I run the same code in command line environment, it shows:

<warning>PHP Warning:  oci_connect(): OCIEnvNlsCreate() failed. There is something wrong with your system - please check that PATH includes the directory with Oracle Instant Client libraries in Psy Shell code on line 1</warning>

Here is some PHP configruation info:

$ php --ri oci8

oci8

OCI8 Support => enabled
OCI8 DTrace Support => disabled
OCI8 Version => 2.2.0
Oracle Run-time Client Library Version => 0.0.0.0.0
Oracle Compile-time Instant Client Version => 12.1

Directive => Local Value => Master Value
oci8.max_persistent => -1 => -1
oci8.persistent_timeout => -1 => -1
oci8.ping_interval => 60 => 60
oci8.privileged_connect => Off => Off
oci8.statement_cache_size => 20 => 20
oci8.default_prefetch => 100 => 100
oci8.old_oci_close_semantics => Off => Off
oci8.connection_class => no value => no value
oci8.events => Off => Off

Statistics =>
Active Persistent Connections => 0
Active Connections => 0

One obvious deviation is "Oracle Run-time Client Library Version => 0.0.0.0.0" I tried the suggestion searched from google:

  • copy all contents of instantclient to Apache/bin directory and remove instantclient directory from PATH But, it doesnot work.

This problem costs me almost 2 days time, but still not solved.

1 Answer 1

0

Make sure the path to Oracle Instant Client libraries is specified in the PATH environment variable.

If you're not sure try run where oci.dll from a command line. If it could not find the file, then it is not in the PATH.

Sign up to request clarification or add additional context in comments.

1 Comment

Thanks for your hints, the command output two oci.dll files. After I delete one . It works now.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.