Error when connecting ORACLE database with PHP

Asked

Viewed 299 times

1

When trying to connect to an Oracle ORACLE database appears the following error:

TNS:System was not Given the SERVICE_NAME in CONNECT_DATA

I have already set up php.ini and included the following lines:

extension=php_oci8.dll
extension=php_oci8_11g.dll
extension=php_oracle.dll

Note: My connection file is as follows:

$conexao = oci_connect('usuario', 'senha', 'nome_do_banco');

  • 1

    Possible solution to your problem: http://stackoverflow.com/questions/20345605/php-oci-connect-tnscould-not-resolve-the-connect-identifier-ora-12154. Specification for SERVICE_NAME: http://docs.oracle.com/cd/B28359_01/server.111/b28320/initparams217.htm Manual oci_connect: http://php.net/manual/en/Function.oci-connect.php

1 answer

0

From what I searched, you need to configure the reference to the Oracle server on the client machine, in the file tnsnames.ora.

A file .ora would have a syntax more or less like this:

SID_LIST_LISTENER =
    (SID_LIST =
        (SID_DESC =
            (SID_NAME = PLSExtProc)
            (ORACLE_HOME = C:\oracle\product\10.2.0\db_1)
            (PROGRAM = extproc)
        )
    )
LISTENER =
    (DESCRIPTION_LIST =
        (DESCRIPTION =
            (ADDRESS =
                (PROTOCOL = TCP)
                (HOST = MYSERVER)
                (PORT = 1521)
            )
        )
    )

Source: https://community.oracle.com/thread/367507

Browser other questions tagged

You are not signed in. Login or sign up in order to post.