I was using PHP 5.2.0-8+etch16 / oci_connect to connect to my company's Oracle DB and show information on our website (accessible to external IPs). Ever since we upgraded our DB version (to 11g Release 11.2.0.4.0), I cannot connect to the database anymore.
The page stays loading ( oci_set_call_timeout
doesn't work), and nothing is shown. I know the code works and the credentials are OK because I use the same code in another page (visible only to internal IPs) and I didn't have any problems after the upgrade. I'm using the following code:
$conn = oci_connect('user', 'password', 'server', 'charset');
if (!$conn) {
$e = oci_error();
trigger_error(htmlentities($e['message'], ENT_QUOTES), E_USER_ERROR);
echo "Error";
}
else{
echo "OK";
}
Running phpinfo, the oci section returns:
oci8
OCI8 Support enabled
Version 1.4.5
Revision $Revision: 305257 $
Active Persistent Connections 0
Active Connections 0
Oracle Instant Client Version 11.1
Temporary Lob support enabled
Collections support enabled
Directive Local Value Master Value
oci8.connection_class no value no value
oci8.default_prefetch 100 100
oci8.events Off Off
oci8.max_persistent -1 -1
oci8.old_oci_close_semantics Off Off
oci8.persistent_timeout -1 -1
oci8.ping_interval 60 60
oci8.privileged_connect Off Off
oci8.statement_cache_size 20 20
In the page accessible only to internal IPs, the version of oci
is 1.4.9 and it is running on a Windows Server 2003 (I know it's old). The external page (the one that doesn't work) has an oci
version of 1.4.5 and runs in a Linux jedi-ng 2.6.25. I don't have access to the linux server (only to the folder where the php/html is stored), but I can run some things using shell_exec()
.
Is it a version problem (I cannot connect to Oracle 11g using an old version of php/oci anymore) or this is just a connection problem that I can solve by trying another approach?
Feel free to ask questions if you need to.
Thanks in advance.
Add this to the top of your test script and see if you get a better error message:
error_reporting(E_ALL|E_STRICT); ini_set('display_errors', 'On');
The key thing is the version of the Oracle libraries used by PHP OCI8, not the version of the database that you are connecting to. There is a bit of overlap in some environments because the libraries could be used from the database software installation. If you have a remote database then PHP OCI8 may (should) use the libraries from Oracle Instant Client (that link is for the 64-bit packages - use the 32-bit Instant Client if you are running 32-bit PHP).
Unless you have OCI8 PHP 2.2.2 and are using Oracle client libraries 18c or later, then oci_set_call_timeout()
won't be available.
If I read your question correctly, you have a problem on Linux? In that case make sure that LD_LIBRARY_PATH is set correctly for your version of the webserver, eg you might need to set it in /etc/sysconfig/httpd
(I don't know your Linux flavor, so this may differ). Often it is much easier to use ldconfig
as shown in the Instant Client installation instructions
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.