Error when tring to connect adodb to Oracle

822 views Asked by At

I have installed WAMP server.

When trying to connect to Oracle it gives this error:

ORA-12541: TNS:no listener

Anyone know how to solve this?

2

There are 2 answers

0
Klaus Byskov Pedersen On

Either your listener isn't started (issue the command lsnrctl start) or your tnsnames.ora is wrong.

0
Shailesh Sonare On

Make changes in php.ini file Enable oci driver uncomment by removing ; semicolon Check for the correct dll file and then

Try this simple class

class AdoConnection {

    public $dbh;

    public function __construct() {
        include_once '../adoconnection/adodb5/adodb.inc.php'; // include your adodb.inc.php file

        $server = "127.0.0.1";
        $user   = "USER/SCHEMA/Database";
        $pwd    = "password";
        $db     = "SID OR Service_Name";

        $this->dbh = NewADOConnection('oci8');
        $this->dbh->Connect(FALSE, $user, $pwd, '(DESCRIPTION = (ADDRESS = (PROTOCOL = TCP)(HOST = ' . $server. ')(PORT = 1521)) (CONNECT_DATA = (SERVICE_NAME = ' . $db . ') (SID = ' . $db . ')))');
    }

    public function select($sql) {
        $result = $this->dbh->Execute($sql);
        $result = $result->GetRows();
        return $result;
    }

    public function insert($sql) {
        $result = $this->dbh->Execute($sql);
        return $result;
    }
}

$dbh = new AdoConnection();

$dbh->select($sql);
$dbh->insert($sql);

Just keep your error_reporting and display_errors On to see the errors.

ini_set('display_errors',1);
error_reporting(E_ALL);