Question

Overall goal of my project is to connect to a Oracle database that is on another server, to query it using PHP, so that I can create charts of the data using JavaScript.

My server is running CentOS

So far I have followed the directions out on the web and have installed oci8 on my server as well as Oracle Insant Client.

I then created a shell script to tunnel to the remote server.

Next I created a test php file to try and connect to the database

<?php
$conn = oci_connect('name', 'pw', 'servername/databasename');
if(!$conn){
        $e = oci_error();
        trigger_error(htmlentities($e['message'], ENT_QUOTES), E_USER_ERROR);
}

oci_close($conn);

?>

When I load this in the browser I am getting the following error

Warning: oci_connect(): ORA-12541: TNS:no listener in /var/www/html/djc/ociConnect.php on line 3 Fatal error: ORA-12541: TNS:no listener in /var/www/html/djc/ociConnect.php on line 6

I have done my research about the error, and I know the major problem is lsnrctl start

does not work, I have no lsnrctl function. I also do not have a TNSNAMES.ORA, or LISTENER.ORA file.

I do not know how to get lsnrctl to work on my server, or if I am even attacking this problem from the correct angle.

Also trying to start sqlplus(which I installed from rpm), returns command not found.

Any suggestions? I am not even sure if I am going about achieving my goal in the correct manor, so any help is greatly appreciated.

Was it helpful?

Solution

I used to connect with:

//Putenv("NLS_LANG=SPANISH_SPAIN.WE8ISO8859P15");
$db="(DESCRIPTION=
     (ADDRESS_LIST=
       (ADDRESS=(PROTOCOL=TCP)
         (HOST=$GLOBALS[dbhost])(PORT=$GLOBALS[dbport])
       )
     )
       (CONNECT_DATA=(SID=$GLOBALS[dbname]))
 )";
 $conn = OCILogon($GLOBALS['dbuser'],$GLOBALS['dbpasswd'],$db);

Replace $GLOBALS['dbuser'], $GLOBALS['dbpasswd'], $GLOBALS[dbhost], $GLOBALS[dbname], $GLOBALS[dbport] accordingly.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top