install and configure OCI8 to connect oracle to php

假装没事ソ 提交于 2019-12-09 01:31:23

问题


I installed oracle 11g and I did create some tables and manipulate it using sql developer, and I am looking for a way to connect oracle with php on hosting site.

I tried but I get error after using this code:

$Conexion_ID =oci_connect($OracleUser, $OraclePassw, $OracleIP);

this is the error:

Call to undefined function oci_connect() 

I've known that I should install and configure OCI8, so I downloaded this file:

http://www.oracle.com/technetwork/database/features/instant-client/index-097480.html

but I don't know in which folder should I them to make the connection work well.


回答1:


Download the PHP Extension from here(Confirm the PHP Version and download for the same, the thread safe[TS] version): http://pecl.php.net/package/oci8/2.0.8/windows

You should be able to find three .dll's

php_oci8.dll, php_oci8_11g.dll and php_oci8_12c.dll

Place all dll's in extension directory, in WAMP it is generally wamp\bin\php\php5.*.*\ext

open the php configuration from the System try of wamp server and add the line:

; Enable only which is required
;extension=php_oci8.dll
extension=php_oci8_11g.dll 
;extension=php_oci8_12c.dll

Restart the Apache server.

EDIT : Sorry I thought the other dll's are the libraries, but instead they are for different oracle versions. In your case enable 11g. Answer updated.

Update 2016-11-07: just wanted to say that latest package can be found here https://pecl.php.net/package/oci8. When I wrote this answer 2.0.8 was latest i guess.




回答2:


if you are using wamp server on windows than you have to use the php_oci8.dll not the oci8.so. You need to download php_oci8.dll and copy it to ext directory under the PHP. If you don't have this extension in your PHP than install it and go to php.ini and add extension=php_oci8.dll.

Please make sure that wamp server have two php.ini files you have to change it on both the places. once everything is done than check with php info that oci 8 installed or not.



来源:https://stackoverflow.com/questions/25519686/install-and-configure-oci8-to-connect-oracle-to-php

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!