PHP oci_connect() TNS:could not resolve the connect identifier (ORA-12154)

instead of ORCL, you may want to put the whole string in oci_connect

(DESCRIPTION = (ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.3.14)(PORT = 1521)) (CONNECT_DATA = (SERVICE_NAME = ORCL) (SID = ORCL)))

PHP code:

oci_connect($username, $password, '(DESCRIPTION = (ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.3.14)(PORT = 1521)) (CONNECT_DATA = (SERVICE_NAME = ORCL) (SID = ORCL)))');

check phpinfo() output "Environment" part, if you don't have ORACLE_HOME, TNS_ADMIN, you need to make those available to your PHP running environment, for apache compiled with php_module

export ORACLE_HOME=/path/to/oracle_home
export TNS_ADMIN=/path/to/tns_admin
apachectl start

for php-cgi or php-fpm

export ORACLE_HOME=/path/to/oracle_home
export TNS_ADMIN=/path/to/tns_admin
/script/to/start/fpm

Tags:

Php

Oracle