3
votes

i am trying to connect Oracle and PHP, i followed PHP manual for connecting and connected success fully by this below way:

 oci_connect('Username','Password', ' (DESCRIPTION =(ADDRESS = (PROTOCOL = TCP)(HOST = mymachine.oracle.com)(PORT = 1521))(CONNECT_DATA = (SERVER = DEDICATED)(SERVICE_NAME = XE)))' );

But Whenever i am using below method

oci_connect('Username','Password', ,'MYDB');

i'm getting this error:

Warning: oci_connect(): ORA-12154: TNS:could not resolve the connect identifier specified in

So, i have checked all the way some one said use Oracle client files i added tnsnames.ora,ORACLE_HOME,TNS_ADMIN and everything done, from the reference of previous questions but still the problem haven't resolved.

am i doing anything wrong, if please help me to get out from this problem.

Thanks in advance.

2

2 Answers

0
votes

Finally found a solution that is the Environment Variable TNS_ADMIN were incorrect.

0
votes

You can create a page with information about your environment by example:

<?php
phpinfo();
?>

By default, create this page in /var/www/html/phpinfo.php

Look for the TNS_ADMIN entry in the Envioriment session.