LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software
User Name
Password
Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.

Notices


Reply
  Search this Thread
Old 04-26-2004, 01:51 AM   #1
dhammika
Member
 
Registered: Dec 2003
Location: Colombo. (Sri Lanka)
Distribution: RH 9, RH AS 3, Fedora Core
Posts: 65

Rep: Reputation: 15
Unhappy PHP Oracle 9i Connection Problem (RH9)


Hello everybody

I config Oracle Server 9i (9.2.0.4.0) on my linux box (2.4.20-8) and try to connect with PHP 4.2.2. (httpd Apache 1.3.22)

Oracle server start and running , test on PHP was O.K. But when try to connect to oracle.

It says

Fatal error:
Call to undefined function:
oci_connect() in /var/www/test/<php_page>.php on line <no>

Any thing wrong. (PHP not support to 9i.)

help me.
 
Old 07-05-2004, 09:45 PM   #2
linux_pioneer
Member
 
Registered: May 2003
Distribution: Solaris 10, Solaris 8.0, Fedora Core 3
Posts: 203

Rep: Reputation: 30
dhammika,

I ran into the same problem but I'm using Fedora which is essentially rh10. I guess the php modules that come w/ redhat don't provide any oracle functions. I had to download the php source code and install with the options:
--with-oci8
--with-apxs2=/usr/local/apache2/bin/apxs(this is assuming that you are using apache2 if not just point to where ever the apxs file is located)

This should work. Now that I've figured that out I'm running into to this other problem. PHP will now recognize the oracle functions but I get this error message:
Warning: ocilogon(): _oci_open_server: ORA-12541: TNS:no listener in /usr/local/apache2/htdocs/oracletest.php on line 6

Maybe you or someone else can figure this one out. Let me know if you were able to get past that 1st issue though.

Last edited by linux_pioneer; 07-05-2004 at 09:46 PM.
 
Old 07-06-2004, 05:05 AM   #3
dhammika
Member
 
Registered: Dec 2003
Location: Colombo. (Sri Lanka)
Distribution: RH 9, RH AS 3, Fedora Core
Posts: 65

Original Poster
Rep: Reputation: 15
Hi linux_pioneer

Yes you are correct , I resolve this problem long time ago and now I am successfully continue my PHP project .

If you can send your code (only the oracle connection part) I think I can help you

Dhammika

Last edited by dhammika; 07-06-2004 at 05:10 AM.
 
Old 07-08-2004, 02:58 AM   #4
linux_pioneer
Member
 
Registered: May 2003
Distribution: Solaris 10, Solaris 8.0, Fedora Core 3
Posts: 203

Rep: Reputation: 30
dhammika,

here's my code:

<?php

$logon = OCILogon('sysdba', 'oracle', 'TSH1');
$sqlCMD = 'SELECT * FROM Contacts';
$query = OCIParse($logon, $sqlCMD);
OCIExecute($query);
while(OCIFetch($query)){
for($x=1; $x <= OCINumCols($query); $x++)
echo OCIResult($query, $x);
echo "<br>";
}
OCILogoff($logon);
?>

this is the error I get with this code:
Warning: ocilogon(): _oci_open_server: ORA-12541: TNS:no listener in /usr/local/apache2/htdocs/oracletest.php on line 6

thanks for the help!

Last edited by linux_pioneer; 07-08-2004 at 02:59 AM.
 
Old 07-08-2004, 05:02 AM   #5
dhammika
Member
 
Registered: Dec 2003
Location: Colombo. (Sri Lanka)
Distribution: RH 9, RH AS 3, Fedora Core
Posts: 65

Original Poster
Rep: Reputation: 15
Are you sure you start the listener

[oracle@keg-ora ]$ lsnrctl start
 
Old 07-10-2004, 04:20 AM   #6
linux_pioneer
Member
 
Registered: May 2003
Distribution: Solaris 10, Solaris 8.0, Fedora Core 3
Posts: 203

Rep: Reputation: 30
Okay got past that error but now I get this one:
ocilogon(): _oci_open_server: Error while trying to retrieve text for error ORA-12154

any clue? can you show me a sample of your code?
 
Old 07-11-2004, 09:57 PM   #7
dhammika
Member
 
Registered: Dec 2003
Location: Colombo. (Sri Lanka)
Distribution: RH 9, RH AS 3, Fedora Core
Posts: 65

Original Poster
Rep: Reputation: 15

did you specify the ORACLE_SID env variable correctly ...



yes. this is the sample code I used as a base. This code from oracle.otn and it is running perfectly try to run it .


<?php

$db_conn = ocilogon( "scott", "tiger" );

$cmdstr = "SELECT * FROM EMP";



$parsed = ociparse($db_conn, $cmdstr);
ociexecute($parsed);



$nrows = ocifetchstatement($parsed, $results);

echo "<html><head><title>Oracle PHP Test</title></head><body>";
echo "<center><h2>Oracle PHP Test</h2><br>";
echo "<table border=1 cellspacing='0' width='50%'>\n<tr>\n";
echo "<td><b>Name</b></td>\n<td><b>Salary</b></td>\n</tr>\n";


for ($i = 0; $i < $nrows; $i++ )
{
echo "<tr>\n";
echo "<td>" . $results["ENAME"][$i] . "</td>";
echo "<td>$ " . number_format($results["SAL"][$i], 2). "</td>";
echo "</tr>\n";

}

echo "<tr><td colspan='2'> Number of Rows: $nrows</td></tr></table>";
echo "<br><em>If you see data, then it works!</em><br></center></body></html>\n";


?>


And the this set of code that use adodb (you can download it) to connect to the ORACLE 9i.




<?php
$UserName = trim($HTTP_POST_VARS['user_id']);
$Address = $HTTP_POST_VARS['address'];
$Name = $HTTP_POST_VARS['name'];
$Email = $HTTP_POST_VARS['email'];


include('adodb/adodb.inc.php');
include('adodb/adodb-errorpear.inc.php');
$server = '192.168.56.3:1521';
$user = 'scott';
$db = ADONewConnection('oci8');

$db->Connect($server, $user, 'tiger', 'keg');

if ($db->Execute("INSERT INTO USERS ( USERID,NAME,ADDRESS,EMAIL) VALUES('$UserName','$Address','$Name','$Email')")==false)
{

echo

'<html>
<head>
<title>Untitled Document</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>

<body bgcolor="#FFFFFF" text="#000000">
<form name="form1" method="post" action="enter_user.php">
<table width="100%" border="0" height="100%">
<tr>
<td>&nbsp;</td>
<td>&nbsp;</td>
<td>&nbsp;</td>
</tr>
<tr>
<td>&nbsp;</td>
<td bgcolor="#000099">
<div align="center"><font face="Arial, Helvetica, sans-serif" color="#FFFFFF">
<font size="5">';

echo " User id <font color=#ffff00> " . $UserName."</font> is already in use. Press back button and enter a different user id.</font></font></div> ";
echo ' </td>
<td>&nbsp;</td>
</tr>
<tr>
<td>&nbsp;</td>
<td>&nbsp;</td>
</tr>
</table>
</form>
</body>
</html>

';

}

else
{
include "enter_user.php";

}


?>

Last edited by dhammika; 07-11-2004 at 10:14 PM.
 
Old 07-12-2004, 05:51 AM   #8
linux_pioneer
Member
 
Registered: May 2003
Distribution: Solaris 10, Solaris 8.0, Fedora Core 3
Posts: 203

Rep: Reputation: 30
got it working. i really appreciate your help. Now i can use oracle instead of mysql (no reason just wanted to try something different). thanks again!
 
Old 03-28-2005, 02:18 PM   #9
emmbec
LQ Newbie
 
Registered: Mar 2005
Posts: 1

Rep: Reputation: 0
How did you got it working, I canīt seem to be able to get it right. I have the listener starting perfectly, and the ORACLE_SID variable set correctly. I still get the same error:


Warning: ocilogon(): _oci_open_server: Error while trying to retrieve text for error ORA-12541 in /export/home/cartorpp/WWW/prueba/test.php on line 3
Oracle Connect Error

this is the php file:

<?php
if ($c=OCILogon("user", "password","qro")) {

echo "Successfully connected to Oracle.\n";

OCILogoff($c);

} else {

$err = OCIError();

echo "Oracle Connect Error " . $err[text];

}
?>

Last edited by emmbec; 03-28-2005 at 02:19 PM.
 
  


Reply


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
Oracle Connection problem nelnel Linux - Software 15 03-29-2006 06:31 AM
Database Configuration Assistent problem Oracle 9.2.0 RH9 agts Linux - Newbie 1 03-31-2004 10:13 AM
RH9: PHP session problem (or Apache problem) fengcn Red Hat 0 12-01-2003 06:32 PM
oracle 9i on RH9 problem.... Txlyo Linux - Software 2 11-15-2003 09:01 AM
Please help with PHP/Oracle RPM install on RH9 pnovess Linux - Newbie 0 08-08-2003 04:54 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Software

All times are GMT -5. The time now is 02:01 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
Open Source Consulting | Domain Registration