Ivo Worluk
Ivo Worluk

Reputation: 11

PHP PDO OCI TNS adatpter error (c:635)

I'm browsing the web for two days in 3 languages, but unfortunately couldn't find an answer (checked the questions here of course, but the one identical was unanswered). There's a virtual server with apache 2.4,php 5.6.7,oracle instant client 12_1 (32 bit). After a few restarts and ini configuration I managed to use PDO odbc and plain oci_connect(). BUT when I try PDO OCI I get this error message:

Error!: SQLSTATE[HY000]: pdo_oci_handle_factory: ORA-12560: TNS:protocol adapter error (ext\pdo_oci\oci_driver.c:635)

The TNS name I set was successfully used in SQL developer to connect.

I'm fairly new to this environment so please ask for the information you might need.

Upvotes: 1

Views: 1226

Answers (1)

FXLima
FXLima

Reputation: 31

Try something like this.

$conn = new Pdo("oci:dbname=(DESCRIPTION = (ADDRESS_LIST = (
                                ADDRESS = (PROTOCOL = TCP)
                                (HOST = {$params['host']} )
                                (PORT = {$params['port']} )
                               ))
                             (CONNECT_DATA = (SID = {$params['servicename']})
                             )); charset=AL32UTF8",
                 $params['user'],
                 $params['password']
                );

Upvotes: 1

Related Questions