problem oci_connect solved..thanks to those involved

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

 



I would have had no problem if I had:

(1) used ZEND
(2) installed php, apache, oracle XE, oci8,instant client

I installed 11g1 Enterprise and that already had a client.

Fedora already had php 5 and apache 2

FINALLY: The following works in the browser.

hr/hr is automatically built in the 11g1 database

<?php // File: anyco.php

require('anyco_ui.inc');

$db = "(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = 127.0.0.1)(PORT = 1521))
(CONNECT_DATA =
(SERVER = DEDICATED)
(SID = LMKIIIGDNSID)
)
)";
// oci_internal_debug(1); // turn on tracing
// $conn = oci_connect("/", "", null, null, OCI_SYSDBA);
// if ($conn=oci_connect('hr', 'hr','LMKIIIGDNSID'))
if ($conn=oci_connect('hr', 'hr',$db))
{
echo "Successfully connected to Oracle.\n";
// OCILogoff($conn);
}
else
{
$err = OCIError();
echo "Oracle Connect Error " . $err;
}

ui_print_header('Departments');
do_query($conn, 'SELECT * FROM DEPARTMENTS');
ui_print_footer(date('Y-m-d H:i:s'));

// Execute query and display results
function do_query($conn, $query)
{
$stid = oci_parse($conn, $query);
$r = oci_execute($stid, OCI_DEFAULT);

print '<table border="1">';
while ($row = oci_fetch_array($stid, OCI_ASSOC+OCI_RETURN_NULLS)) {
print '<tr>';
foreach ($row as $item) {
print '<td>'.
($item ? htmlentities($item) : ' ').'</td>';
}
print '</tr>';
}
print '</table>';
}

?>

What did I do:

in the file /etc/rc.d/init.d/httpd

I inserted statements starting with export position indicated by the surrounding code.

# Path to the apachectl script, server binary, and short-form for messages.
apachectl=/usr/sbin/apachectl
httpd=${HTTPD-/usr/sbin/httpd}
prog=httpd
pidfile=${PIDFILE-/var/run/httpd.pid}
lockfile=${LOCKFILE-/var/lock/subsys/httpd}
RETVAL=0
# new statements here
export ORACLE_HOSTNAME=localhost.localdomain
export TNS_ADMIN=/u01/app/oracle/product/11.1.0/db_1/network/admin
export ORACLE_BASE=/u01/app/oracle

export ORACLE_HOME=/u01/app/oracle/product/11.1.0/db_1
export ORACLE_SID=LMKIIIGDNSID
export LD_LIBRARY_PATH /u01/app/oracle/product/11.1.0/db_1/lib:/lib:/usr/lib

# new statements above

# The semantics of these two functions differ from the way apachectl does
# things -- attempting to start while running is a failure, and shutdown
# when not running is also a failure. So we just do it the way init scripts
# are expected to behave here.
start() {
echo -n $"Starting $prog: "
LANG=$HTTPD_LANG daemon --pidfile=${pidfile} $httpd $OPTIONS
RETVAL=$?
echo
$RETVAL = 0 && touch ${lockfile}
return $RETVAL
}

I had put similar statements in /etc/httpd/conf/httpd.conf (setenv). I will remove these statements (and see if it still works!)

It stopped working...so:

into /etc/httpd/conf/httpd.conf I had to add:
### Section 1: Global Environment
#
# The directives in this section affect the overall operation of Apache,
# such as the number of concurrent requests it can handle or where it
# can find its configuration files.
#

SetEnv ORACLE_HOSTNAME localhost.localdomain
SetEnv TNS_ADMIN /u01/app/oracle/product/11.1.0/db_1/network/admin
SetEnv ORACLE_BASE /u01/app/oracle
SetEnv ORACLE_HOME /u01/app/oracle/product/11.1.0/db_1
SetEnv ORACLE_SID lmkiiiGDNSID
SetEnv ORACLE_TERM xterm
SetEnv LD_LIBRARY_PATH /u01/app/oracle/product/11.1.0/db_1/lib:/lib:/usr/lib

#
# Don't give away too much information about all the subcomponents
# we are running. Comment out this line if you don't mind remote sites
# finding out what major optional modules you are running
ServerTokens OS

Just noticed: OOOOPS!

in /etc/phi.ini I have: (tomorrow I'll see if it still works without this)

237 ; Note: If this directive is empty, PHP will let the user modify ANY
238 ; environment variable!
239 ; safe_mode_allowed_env_vars = PHP_
240
241 ORACLE_HOSTNAME="localhost.localdomain"
242 ORACLE_BASE="/u01/app/oracle"
243 ORACLE_HOME="/u01/app/oracle/product/11.1.0/db_1"
244 ORACLE_SID="lmkiiiGDNSID"
245 LD_LIBRARY_PATH="/u01/app/oracle/product/11.1.0/db_1/lib:/lib:/usr/lib"
246 TNS_ADMIN="/u01/app/oracle/product/11.1.0/db_1/network/admin"
247


      


-- 
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