Re: Can't connect to Oracle
| From: | Leon Santos Filho | Date: | Tue, 13 Mar 2001 16:15:04 +0000 |
| Subject: | Re: Can't connect to Oracle | ||
| References: | 1 | Groups: | php.windows |
| Request: | Send a blank email to php-windows+get-6001@lists.php.net to get a copy of this message | ||
Hi!
I get this code here and it works very well. It was a Jean-Christophe
suggestion.
You can obtain TNS string from file TNSNAMES.ORA.
Good Luck!
Leon
<?php
putenv("ORACLE_SID=badm");
putenv("ORACLE_HOME=D:\ORANT");
$tns = "(DESCRIPTION = (ADDRESS_LIST =(ADDRESS = (PROTOCOL = TCP)(HOST =
bhz_oracle_1)(PORT = 1521))) (CONNECT_DATA = (SID = badm) ) )";
$connect=OCIPLogon("user","password",$tns) or die("It's not possible
to
connect");
$sql = "select * from CentrosCusto";
$result = OCIParse($connect,$sql);
OCIExecute($result) or die("It's not possible to query");
echo("<TABLE>");
while(OCIFetch($result)) {
$CC = OCIResult($result,1);
$CCNome = OCIResult($result,2);
echo('<TR><TD>' . $CC . '</TD><TD>' . $CCNome .
'</TD></TR>');
}
echo("</TABLE>");
?>
----- Original Message -----
From: Herbert Groot Jebbink <hgj@xs4all.nl>
To: <php-windows@lists.php.net>
Sent: Monday, March 12, 2001 1:48 PM
Subject: [PHP-WIN] Can't connect to Oracle
> Hi,
>
> I can't connect from a win95/Apache setup to a Oracle database
>
> - The PHP version is 4.04pl1 (Nusphere)
> - The location for tnsnames.ora is c:\orawin95\network\admin\tnsnames.ora
> - De Oracle version is 7.3.4.0.0
> - De SQL*NET client version is 2.3.4.0.0
> - Using the SQL PLUS 3.3 client on this machine works fine:
> - The Oracle module is active in php.ini
>
> The test program:
>
> <?php
> putenv('ORACLE_HOME=c:\orawin95');
> putenv("ORACLE_SID=WKDS");
> $conn = ora_plogon("hgj@wkds", "hgj");
> ?>
>
> The result:
>
> Warning: Unable to connect to ORACLE (ORA-12154: TNS:could not resolve
> service name) in /www/data/ontwikkel/test/php/test3.php on line 5
>
> Someone a idea whats wrong?
>
> Greetings, Herbert
>
> --
> The Trans-Siberian Railroad Page:
> http://herbert.groot.jebbink.nl
>
> --
> PHP Windows Mailing List (http://www.php.net/)
> To unsubscribe, e-mail: php-windows-unsubscribe@lists.php.net
> For additional commands, e-mail: php-windows-help@lists.php.net
> To contact the list administrators, e-mail: php-list-admin@lists.php.net