yong cheng
yong cheng

Reputation: 11

PHP cannot connect oracle in command line

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:

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:

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

Upvotes: 1

Views: 606

Answers (1)

AterLux
AterLux

Reputation: 4654

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.

Upvotes: 0

Related Questions