How to specify database of OCI_CONNECT

Viewed 12

Goog afternoon.

I'm trying to implement a conection with Oracle Database from PHP. But i'm not getting success.

$conn_oracle = oci_connect('username', 'password', '10.1.11.7');

Please, witch the order of parameters?

1 Answers

Check "Oracle Database Name Connection Identifiers" on page 104 of the free The Underground PHP and Oracle Manual PDF.

Commonly you probably need just the service name of the database that is running on your computer. If that name was XEPDB1, then your PHP code would then use

$conn_oracle = oci_connect('username', 'password', '10.1.11.7/XEPDB1');

If the database service is running on a non-default port, you might to include that:

$conn_oracle = oci_connect('username', 'password', '10.1.11.7:1522/XEPDB1');

(The default port is 1521).

Typically to find a service name you could (i) ask someone else using the DB (ii) look at other connection strings you use in other tools (iii) ask the DBA (iv) log into a terminal where the DB is running, set the Oracle environment (on Linux etc with source /usr/local/bin/oraenv), and then run lsnrctl status (v) trying common names: XEPDB1, orclpdb, or orclpdb1.

Related