Discussions
Categories
- 196.9K All Categories
- 2.2K Data
- 239 Big Data Appliance
- 1.9K Data Science
- 450.3K Databases
- 221.7K General Database Discussions
- 3.8K Java and JavaScript in the Database
- 31 Multilingual Engine
- 550 MySQL Community Space
- 478 NoSQL Database
- 7.9K Oracle Database Express Edition (XE)
- 3K ORDS, SODA & JSON in the Database
- 546 SQLcl
- 4K SQL Developer Data Modeler
- 187K SQL & PL/SQL
- 21.3K SQL Developer
- 295.9K Development
- 17 Developer Projects
- 138 Programming Languages
- 292.6K Development Tools
- 107 DevOps
- 3.1K QA/Testing
- 646K Java
- 28 Java Learning Subscription
- 37K Database Connectivity
- 155 Java Community Process
- 105 Java 25
- 22.1K Java APIs
- 138.1K Java Development Tools
- 165.3K Java EE (Java Enterprise Edition)
- 18 Java Essentials
- 160 Java 8 Questions
- 86K Java Programming
- 80 Java Puzzle Ball
- 65.1K New To Java
- 1.7K Training / Learning / Certification
- 13.8K Java HotSpot Virtual Machine
- 94.3K Java SE
- 13.8K Java Security
- 204 Java User Groups
- 24 JavaScript - Nashorn
- Programs
- 442 LiveLabs
- 38 Workshops
- 10.2K Software
- 6.7K Berkeley DB Family
- 3.5K JHeadstart
- 5.7K Other Languages
- 2.3K Chinese
- 171 Deutsche Oracle Community
- 1.1K Español
- 1.9K Japanese
- 232 Portuguese
PHP ORACLE Connection Problem
Hi,
PHP, OCI8 installed on the same machine (where oracle database 10.2.0.1.0 has been installed).
i am able to run test.php (oracle database connection with php and getting data) by user oracle and root on command line.
but with a different user say (xsdu) not able to run by command prompt although exporting all environment variable like ORACLE_HOME and LD_LIBRARY_PATH etc..
this i am testing to run the code by browser which is not working.
Please help..
Thanks
--
PHP, OCI8 installed on the same machine (where oracle database 10.2.0.1.0 has been installed).
i am able to run test.php (oracle database connection with php and getting data) by user oracle and root on command line.
but with a different user say (xsdu) not able to run by command prompt although exporting all environment variable like ORACLE_HOME and LD_LIBRARY_PATH etc..
this i am testing to run the code by browser which is not working.
Please help..
Thanks
--
Tagged:
Answers
-
Your script, the OS, and the edition of Oracle would be useful information to share.
Check "Commonly Seen Connection and Environment Errors" on page 107 of http://www.oracle.com/technetwork/topics/php/underground-php-oracle-manual-098250.html
There are various things that could be the cause e.g. perhaps the section "Check Apache Has Oracle File Access" is relevant. -
=======================================Script=========================================
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>
</head>
<body>
<?php
echo "Oracle Connect program";
//define('DB_SERVER', '128.233.1.24/comdb');
define('DB_SERVER', '10.141.40.42:1521/DF4BD');
define('DB_USERNAME', 'ekocon');
define('DB_PASSWORD', 'eko_abc');
define('DB_DATABASE', 'BF4DB1');
$conn= oci_connect(DB_USERNAME, DB_PASSWORD, DB_SERVER)
or die(oci_error());
if (!$conn) {
$e = oci_error();
trigger_error(htmlentities($e['message'], ENT_QUOTES), E_USER_ERROR);
}
$query = "select test1, test2 from test";
//$query = "select * from eka_markers";
$stid = oci_parse($conn, $query);
oci_execute($stid);
echo "<table border='1'>\n";
while ($row = oci_fetch_array($stid, OCI_ASSOC+OCI_RETURN_NULLS)) {
echo "<tr>\n";
foreach ($row as $item) {
echo " <td>" . ($item !== null ? htmlentities($item, ENT_QUOTES) : " ") . "</td>\n";
}
echo "</tr>\n";
}
echo "</table>\n";
?>
</body>
</html>
==================================================================================
======================================*OS*========================================
[[email protected] html]# uname -a
Linux b4pcc1.redhat.com 2.6.18-194.el5xen #1 SMP Tue Mar 16 22:01:26 EDT 2010 x86_64 x86_64 x86_64 GNU/Linux
[[email protected] html]#
Red Hat Enterprise Linux Server release 5.5
======================================ORACLE EDITION=================================
Oracle Database 10g Enterprise Edition Release 10.2.0.1.0 - 64bit Production
===================================================================================
I think you have pointed the right problem - "Check Apache Has Oracle File Access". But how to fix it..
i have given permission to tnsnames.ora as
-rwxrwxr-x 1 oracle oinstall 550 Mar 5 11:38 tnsnames.ora
...
Please help.. -
The problem was solved. You have rightly pointed that this has some permission issue.
The clue was on page 108 of the book you referred - "If you built PHP withan ORACLE_HOME, then check the Oracle home directory is
readable by the Apache process owner"
Then i thought who is process owner and this was apache user.
then i dod su - apache and it was telling "The account is currently not available".
It required a shell creation for apache user.
chsh -s /bin/bash apache.
Then by changing directory step by step to tnsnames.ora.
i found that in ORACLE_HOME /product has permission as drwxrwx---.
so i made it drwxrwxr-x and it works.
Thank you so much.
----- -
There was a changePerm.sh script in a later 10.2 patchset to help set permissions. Oracle 10g Express Edition and Oracle 11g didn't have the same restrictive settings, so generally just the home directory needed extra access granted in these other releases.
If you're uncomfortable (for whatever reasons) with granting the extra access, you could use PHP with the free Oracle Instant Client libraries. -
On this same machine i installed perl-DBI and Oracle-DBD.
i can run a perl script (which connects to a ORACLE database) with command line and getting the output but when i run it through web it gives the following error.
--------------------------
[Mon Apr 08 11:10:49 2013] [error] [client 10.141.6.213] install_driver(Oracle) failed: Can't load '/usr/lib64/perl5/site_perl/5.8.8/x86_64-linux-thread-multi/auto/DBD/Oracle/Oracle.so' for module DBD::Oracle: libclntsh.so.10.1: cannot open shared object file: No such file or directory at /usr/lib64/perl5/5.8.8/x86_64-linux-thread-multi/DynaLoader.pm line 230.
---------------------------
i can run php script through web which fetch data from a oracle database on this machine.
---
Please help.
--- -
You probably need to set the various Oracle environment variables so the webserver has access to them.
There are some recent threads in this forum that might help you find how & where to set them for
your setup.
This discussion has been closed.