Discussions
Categories
- 196.9K All Categories
- 2.2K Data
- 239 Big Data Appliance
- 1.9K Data Science
- 450.4K Databases
- 221.7K General Database Discussions
- 3.8K Java and JavaScript in the Database
- 31 Multilingual Engine
- 550 MySQL Community Space
- 478 NoSQL Database
- 7.9K Oracle Database Express Edition (XE)
- 3K ORDS, SODA & JSON in the Database
- 546 SQLcl
- 4K SQL Developer Data Modeler
- 187K SQL & PL/SQL
- 21.3K SQL Developer
- 295.9K Development
- 17 Developer Projects
- 138 Programming Languages
- 292.6K Development Tools
- 107 DevOps
- 3.1K QA/Testing
- 646K Java
- 28 Java Learning Subscription
- 37K Database Connectivity
- 155 Java Community Process
- 105 Java 25
- 22.1K Java APIs
- 138.1K Java Development Tools
- 165.3K Java EE (Java Enterprise Edition)
- 18 Java Essentials
- 160 Java 8 Questions
- 86K Java Programming
- 80 Java Puzzle Ball
- 65.1K New To Java
- 1.7K Training / Learning / Certification
- 13.8K Java HotSpot Virtual Machine
- 94.3K Java SE
- 13.8K Java Security
- 204 Java User Groups
- 24 JavaScript - Nashorn
- Programs
- 442 LiveLabs
- 38 Workshops
- 10.2K Software
- 6.7K Berkeley DB Family
- 3.5K JHeadstart
- 5.7K Other Languages
- 2.3K Chinese
- 171 Deutsche Oracle Community
- 1.1K Español
- 1.9K Japanese
- 232 Portuguese
oci_pconnect(): ORA-12541: TNS:no listener (Read details)
I have created a database for E-voting system on SQL developer Oracle 12c by CREATE_TABLE commands and INSERT_INTO commands for making and inserting data into the tables. In 12c, I had a connection call "Qurat" to the database. I did not use the create database command.
I need to connect it to a webpage using PHP. I've PHP 5.6.19 and WAMP 3.0.0 on Windows10 [Localhost runs smoothly, APACHE is connected, all services running. WAMP is green]
I downloaded the instant client OCI8 for Oracle and did the configuration in PHP.ini file.
Now when I run the following script:<?php
<?php $c = oci_pconnect("scott", "tiger", "localhost/orcle"); if(!$c) {echo 'Connected';} else {echo 'failed';} $result = oci_parse($c, "select fname from NIC where NICno=4250167366706"); if (!$result){ $err = oci_error(); echo "Could not parse the oci"; exit; } $r = oci_execute($result); if (!$r) { $error = oci_error($conn); echo "Could not execute." . $error['message']; exit; } oci_close(); ?>
It gives me the following output which indicates that the connection is successfully done. But there's issue in parsing it.
Warning: oci_pconnect(): ORA-12541: TNS:no listener in C:\wamp\www\Hello\1.php on line 3 Connected Warning: oci_parse() expects parameter 1 to be resource, boolean given in C:\wamp\www\Hello\1.php on line 7 Could not parse the oci
I have checked the 'Services' , listener.ora file, tnsnames.ora file. I've also tried reloading using lsnrctl and it successfully does that. I have tried almost every solution on the internet.
I have two OracleHomeUser(s) although I use only one of them. I tried deleting the folder for OracleHomeUser1 manually by shift+delete but the deletion process had to skip some files since they are being used somewhere else. Is this problem because of this?
or Am i referring to the database in a wrong way?
This is the output i get from lsnrctl status
Answers
-
Hi 3211911,
Looks like your listener is actually listening on "PORT=1522" from screenshot in output from "lsnrctl status"
Try changing your oci_pconnect "easy connect" string to include the port number 1522 (as without specifying it, it will default to port 1521):
$c = oci_pconnect("scott", "tiger", "localhost:1522/orcle"); if(!$c) {echo 'Connected';} else {echo 'failed';}
This page may help in understanding connect strings using oci_pconnect()
...and even though the above error is a "Warning", it basically saying the connection failed. Not sure why your code thinks it "Connected" as oci_pconnect should have returned "FALSE".
Cheers,
Gaz.
-
It says 'Connected' because the condition logic is inverted: if(!$c) should be if($c)
-
thanks cj