Php, Oracle on Mac, with strange behaviour

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Dear List,

I have a puzzler, which I can't seem to fix.
To summarise, I have installed PHP, apache from source and the oracle client (details below). I then construct a simple PHP script to connect to my oracle database. When I run the script from the command line, it works perfectly, and returns rows from the database.

	bash$ php oracle.php
Using : /opt/oracle/instanceclient, ORACLE_HOME=/opt/oracle/ instanceclient
	Successfully connected to Oracle.
<table border="1"><tr><td>71</td><td>71</td><td>421.4983</ td><td>421.4983</td><td>C23 H27 N5 O3</td><td>C23 H27 N5 O3</td>

Buuuut, when I try to view this through a browser, it returns this error:

Using : /opt/oracle/instanceclient, ORACLE_HOME=/opt/oracle/ instanceclient Warning: ocilogon() [function.ocilogon]: OCIEnvNlsCreate() failed. There is something wrong with your system - please check that LD_LIBRARY_PATH includes the directory with Oracle Instant Client libraries in/Library/WebServer/Documents/oracle.php on line 25
	Oracle Connect Error

Here are the details of my installation and a few things I have tried:

Apache:
Installed apache (httpd-2.2.11) with the following configuration: -- prefix=/usr/local/apache --enable-module=so
No Errors

PHP
Installed PHP (php-5.2.9) with the following configuration:
--with-apxs2 -enable-cli --with-mysql=/usr/local/mysql/ --exec- prefix=/usr --localstatedir=/var --libexecdir=/System/Library/Apache /Modules --enable-shared=max --with-gd=/usr/local --with-zlib -- with-oci8=instantclient,/opt/oracle/instanceclient -enable-layout =Darwin -enable-mods-shared=all --with-apxs2=/usr/local/apache2/bin/ apxs --with-config-file-path=/usr/local/apache2/conf --enable-si
gchild
No errors

Oracle Client
Installed Basic + all others in /opt/oracle/instanceclient
No errors

Oracle (Version 11g) is installed on a different server

I will paste the PHP script I am using at the bottom of the mail.
Now, as I said, it is working fine through the command line, so everything is setup fine, so I figure it must be a permissions problem. Hence, I chmod -R 755 $ORACLE_HOME and have tried running apache as lots of different users, but to no avail

Thanks in advance
Mark

##### PHP SCRIPT #####
<?php
putenv("ORACLE_SID=orcl");
putenv("LD_LIBRARY_PATH=/opt/oracle/instanceclient");
$username = "#####";### I have hidden this for security
$passwd = "#####"; ### I have hidden this for security
echo("Using : ". getenv("LD_LIBRARY_PATH"));
echo ", ORACLE_HOME=".getenv("ORACLE_HOME");
$db="(DESCRIPTION=
           (ADDRESS=(PROTOCOL=TCP)
(HOST=########)(PORT=1521) ### I have hidden this for security
           )
(CONNECT_DATA=(SERVER=DEDICATED)(SID=orcl) (SERVICE_NAME=orcl))
     )";

if ($c = OCILogon($username,$passwd,$db)) {
        echo "Successfully connected to Oracle.n";
        $s = OCIParse($c, "select * from COMPOUNDS WHERE rownum=1");
        OCIExecute($s, OCI_DEFAULT);
        print '<table border="1">';
        while ($row = oci_fetch_array($s, OCI_RETURN_NULLS)) {
                print '<tr>';
                foreach ($row as $item) {
print '<td>'.($item? htmlentities($item):'&nbsp;').'</td>';
                }
                print '</tr>';
        }
        OCILogoff($c);
} else {
        $err = OCIError();
echo "Oracle Connect Error " . $err[text]. " ". $err[message];
}
echo("<br />\n");

##### END #####
_____________________________

Mark Halling-Brown
Higher Scientific Officer,
Computational Biology & Chemogenomics, Cancer Therapeutics,
The Institute of Cancer Research
15 Cotswold Road
Belmont, Surrey SM2 5NG, UK
Tel: (+44)-20-8722-4300 (ext: 4659)
Email: mhallingbrown@xxxxxxxxx
Web: http://www.markyhb.co.uk

"A cynic is what an idealist calls a realist"


The Institute of Cancer Research: Royal Cancer Hospital, a charitable Company Limited by Guarantee, Registered in England under Company No. 534147 with its Registered Office at 123 Old Brompton Road, London SW7 3RP.

This e-mail message is confidential and for use by the addressee only.  If the message is received by anyone other than the addressee, please return the message to the sender by replying to it and then delete the message from your computer and network.

--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [PHP Users]     [Postgresql Discussion]     [Kernel Newbies]     [Postgresql]     [Yosemite News]

  Powered by Linux