Click here to Skip to main content
15,945,119 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
hi friends,
i know the connection with mysql in php. and i done several project using mysql. now i want to connect oracle 10g data base with php.
i use the oci_connect (username, passwrd, database) to connect with oracle, but it display error "Fatal error: Call to undefined function oci_connect()" can you help me about this how to make connection with oracle and any extra things i have to add for connection.
thanks in advance.
Posted

1 solution

These are the notes to oci_connect() from the PHP manual:

Note: If you're using PHP with Oracle Instant Client, you can use easy connect naming method described here: » http://download-west.oracle.com/docs/cd/B12037_01/network.101/b10775/naming.htm#i498306. Basically this means you can specify "//db_host[:port]/database_name" as database name. But if you want to use the old way of naming you must set either ORACLE_HOME or TNS_ADMIN. 

Note: The second and subsequent calls to oci_connect() with the same parameters will return the connection handle returned from the first call. This means that queries issued against one handle are also applied to the other handles, because they are the same handle. This behaviour is demonstrated in Example 1 below. If you require two handles to be transactionally isolated from each other, you should use oci_new_connect() instead. 

Note: In PHP versions before 5.0.0 you must use ocilogon() instead. This name still can be used, it was left as the alias of oci_connect() for downwards compatability. This, however, is deprecated and not recommended. 

Check the first and last notes. Do they apply to you?

Peter


[update]

Here's some more from the manual, about setting up to use OCI8 (the Oracle interface).

Requirements
You will need the Oracle client libraries to use this extension. Windows users will need libraries with version at least 10 to use the php_oci8.dll. 

Note: This extension does not support Oracle 8 client libraries anymore. Though you still can connect to Oracle 8 servers as long as the client library (v.9+) supports this. 


The most convenient way to install all the required files is to use Oracle Instant Client, which is available from here: » http://www.oracle.com/technology/tech/oci/instantclient/instantclient.html. To work with OCI8 module "basic" version of Oracle Instant Client is enough. Instant Client does not need ORACLE_SID or ORACLE_HOME environment variables set. You still may need to set LD_LIBRARY_PATH and NLS_LANG, though. 

Before using this extension, make sure that you have set up your Oracle environment variables properly for the Oracle user, as well as your web daemon user. These variables should be set up before you start your web-server. The variables you might need to set are as follows: 

ORACLE_HOME 
ORACLE_SID 
LD_PRELOAD 
LD_LIBRARY_PATH 
NLS_LANG 
For less frequently used Oracle environment variables such as TNS_ADMIN, TWO_TASK, ORA_TZFILE, and the various Oracle globalization settings like ORA_NLS33, ORA_NLS10 and the NLS_* variables refer to Oracle documentation. 
[/update]

If you need any more help, I strongly recommend that you download the PHP manual.
 
Share this answer
 
v2
Comments
niravbhavsar 8-Jun-12 3:36am    
i am using 5.3.0 version. but don't understand clearly.
Peter_in_2780 8-Jun-12 3:49am    
See my updated answer.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900