Solved

php oracle connection error

Posted on 2007-11-15
3
6,655 Views
Last Modified: 2013-12-19
hi,

i installed oracle 10g express on my window xp machine.

i am trying to connect the database with php (5.2.3)

here is my connection string:
$conn = oci_connect('testdb', 'testdb', 'TestDB');

but i am get the following errors displayed on my page:

Warning: oci_connect() [function.oci-connect]: ORA-12154: TNS:could not resolve the connect identifier specified in E:\WEBAPPS\WEBDEV\VAN\dbconnect\oracledbc.php on line 3

Warning: oci_parse() expects parameter 1 to be resource, boolean given in E:\WEBAPPS\WEBDEV\VAN\oraclesample.php on line 7

Warning: oci_execute() expects parameter 1 to be resource, null given in E:\WEBAPPS\WEBDEV\VAN\oraclesample.php on line 8

Warning: oci_fetch_all() expects parameter 1 to be resource, null given in E:\WEBAPPS\WEBDEV\VAN\oraclesample.php on line 10

Oracle PHP Test

Name Salary
Number of Rows:  

If you see data, then it works!


Warning: oci_free_statement() expects parameter 1 to be resource, null given in E:\WEBAPPS\WEBDEV\VAN\oraclesample.php on line 29

Warning: oci_close() expects parameter 1 to be resource, boolean given in E:\WEBAPPS\WEBDEV\VAN\oraclesample.php on line 30
PHP Warning: oci_connect() [function.oci-connect]: ORA-12154: TNS:could not resolve the connect identifier specified in E:\WEBAPPS\WEBDEV\VAN\dbconnect\oracledbc.php on line 3 PHP Warning: oci_parse() expects parameter 1 to be resource, boolean given in E:\WEBAPPS\WEBDEV\VAN\oraclesample.php on line 7 PHP Warning: oci_execute() expects parameter 1 to be resource, null given in E:\WEBAPPS\WEBDEV\VAN\oraclesample.php on line 8 PHP Warning: oci_fetch_all() expects parameter 1 to be resource, null given in E:\WEBAPPS\WEBDEV\VAN\oraclesample.php on line 10 PHP Warning: oci_free_statement() expects parameter 1 to be resource, null given in E:\WEBAPPS\WEBDEV\VAN\oraclesample.php on line 29 PHP Warning: oci_close() expects parameter 1 to be resource, boolean given in E:\WEBAPPS\WEBDEV\VAN\oraclesample.php on line 30

what could be here the problem

0
Comment
Question by:eaweb
  • 2
3 Comments
 
LVL 142

Accepted Solution

by:
Guy Hengel [angelIII / a3] earned 500 total points
ID: 20288645
> ORA-12154: TNS:could not resolve the connect identifier
makes me assume that testdb is not correct tns name... maybe testdb.world is?
for that to correct, we need to look at the tnsnames.ora and sqlnet.ora file in the relevant oracle home directory \network\admin
0
 

Author Comment

by:eaweb
ID: 20289320
yes angleIII, problem solved

<?php
if ($c = oci_connect ("hr", "hr", "xe")) {
  echo "Successfully connected to Oracle.\n";
  oci_close($c);
} else {  
  echo "Oracle Connect Error ";
}
?>

the tns name was "xe"

do you know some site where i can get some query display sample code for php oracle just like the site asp101?
0
 
LVL 142

Expert Comment

by:Guy Hengel [angelIII / a3]
ID: 20290016
"everything" for php should be findable on php.net (via google) or the main index of the language reference.
0

Featured Post

PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
php string detection problem 7 34
Loop through multiple arrays 13 29
How do uses indexes to maximize MySQL Searches 14 34
Email query results in HTML 6 20
This post first appeared at Oracleinaction  (http://oracleinaction.com/undo-and-redo-in-oracle/)by Anju Garg (Myself). I  will demonstrate that undo for DML’s is stored both in undo tablespace and online redo logs. Then, we will analyze the reaso…
These days socially coordinated efforts have turned into a critical requirement for enterprises.
This video shows how to set up a shell script to accept a positional parameter when called, pass that to a SQL script, accept the output from the statement back and then manipulate it in the Shell.
The viewer will learn how to create a basic form using some HTML5 and PHP for later processing. Set up your basic HTML file. Open your form tag and set the method and action attributes.: (CODE) Set up your first few inputs one for the name and …

809 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question