LinuxQuestions.org
Register a domain and help support LQ
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices



Reply
 
Search this Thread
Old 10-12-2010, 10:35 AM   #1
angel115
Member
 
Registered: Jul 2005
Location: France / Ireland
Distribution: Debian mainly, and Ubuntu
Posts: 494

Rep: Reputation: 75
Error connecting to Oracle database from PHP


Hello There,

I've just installed the Oracle Instant client using this:
https://help.ubuntu.com/community/PHPOracle

the phpinfo() show me that oci8 is enable, but when I try to query that database I've got the following message:

PHP Code:
<?php
$credentials 
oci_connect('user''pw''IP_Address');
$query oci_parse($credentials'SHOW TABLES');
oci_execute($query);
$res oci_fetch_array($queryOCI_ASSOC);

echo 
"<pre>";
echo 
"test\n";
var_dump($res);
echo 
"<pre>";
?>

Code:
Warning: oci_connect(): ORA-12504: TNS:listener was not given the SERVICE_NAME in CONNECT_DATA in /usr/local/reports/share/index.php on line 2
Warning: oci_parse() expects parameter 1 to be resource, boolean given in /usr/local/reports/share/index.php on line 3
Warning: oci_execute() expects parameter 1 to be resource, null given in /usr/local/reports/share/index.php on line 4
Warning: oci_fetch_array() expects parameter 1 to be resource, null given in /usr/local/reports/share/index.php on line 5
PS: I've copy the tnsnames.ora from the database server to the /etc/tnsnames.ora of the web server.

Any lead on how to troubleshoot would be welcome.

Angel

Last edited by angel115; 10-12-2010 at 10:53 AM.
 
Old 10-12-2010, 12:53 PM   #2
14moose
Member
 
Registered: May 2010
Posts: 83

Rep: Reputation: Disabled
Hi -

The problem is here:
Quote:
Warning: oci_connect(): ORA-12504: TNS:listener was not given the SERVICE_NAME in CONNECT_DATA...
The other errors are simply because "oci_connect()" failed.

STRONG SUGGESTION:
Definitely modify your code so that your page fails gracefully if the connection is unavailable.

TROUBLESHOOTING:
The "oci_connect()" problem is probably Oracle configuration (and not a PHP coding issue per se).

Please look at these links. Once you can connect to Oracle with sqlplus (from the command line), then your oci_connect() should work, too. Start by checking your tnsnames.ora and sqlnet.ora configuration files:

http://www.dbmotive.com/oracle_error...?errcode=12504

http://forums.oracle.com/forums/thre...07935&tstart=0

http://www.dbasupport.com/forums/arc...p/t-11409.html
 
1 members found this post helpful.
Old 10-13-2010, 10:39 AM   #3
angel115
Member
 
Registered: Jul 2005
Location: France / Ireland
Distribution: Debian mainly, and Ubuntu
Posts: 494

Original Poster
Rep: Reputation: 75
Ok thanks,

The following code is ok:
PHP Code:
<?php
$credentials 
oci_connect('user''pw''IP_Address/Database_Name');
$query oci_parse($credentials'SHOW TABLES');
oci_execute($query);
$res oci_fetch_array($queryOCI_ASSOC);

echo 
"<pre>";
echo 
"test\n";
var_dump($res);
echo 
"<pre>";
?>
now I've:
Code:
Warning: oci_connect(): ORA-01017: invalid username/password; logon denied
which is much better.

although I still can't connect, this error message is more self explanatory.

I'll see with the BD admin for that

Thanks again

Last edited by angel115; 10-13-2010 at 10:42 AM.
 
  


Reply

Tags
oci8 oracle php


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Configure php to connect with oracle vs224 Linux - Newbie 5 08-24-2010 02:55 PM
How can I connect OpenOffice 3 to Oracle Database? Felipe Linux - Software 2 03-16-2009 06:17 AM
cannot connect to oracle 10g xe database admin page sparrott Linux - Networking 4 03-20-2006 03:46 PM
connect to Windows Oracle database turbo_acura Linux - Software 1 11-03-2005 01:35 AM
COnnect Oracle Database in Linux by C++ program!! nelnel Linux - Software 4 05-24-2005 11:13 PM


All times are GMT -5. The time now is 07:28 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration