Discussions
Categories
- 196.8K 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
- 544 SQLcl
- 4K SQL Developer Data Modeler
- 187K SQL & PL/SQL
- 21.3K SQL Developer
- 295.9K Development
- 17 Developer Projects
- 138 Programming Languages
- 292.5K 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
- 439 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
Warning: oci_pconnect(): OCIEnvNlsCreate() failed.

ebsappsgirl
Member Posts: 169
So I installed apache 2, then PHP, and Oci8. Then I installed my database. I installed all the other packages Oracle said that I needed. Apache is working great, the database is fine.
I'm trying to connect to my database.
Here is the php code I'm using to test the connection first in /var/www/html/oci8.php
<?php
$c = oci_pconnect("hr", "welcome", "lionheartdb");
if (!$c) {
$e = oci_error();
trigger_error('Could not connect to database: '. $e['message'],E_USER_ERROR);
}
$s = oci_parse($c, "select city from locations order by city");
if (!$s) {
$e = oci_error($c);
trigger_error('Could not parse statement: '. $e['message'], E_USER_ERROR);
}
$r = oci_execute($s);
if (!$r) {
$e = oci_error($s);
trigger_error('Could not execute statement: '. $e['message'], E_USER_ERROR);
}
echo "<table border='1'>\n";
$ncols = oci_num_fields($s);
echo "<tr>\n";
for ($i = 1; $i <= $ncols; ++$i) {
$colname = oci_field_name($s, $i);
echo " <th><b>".htmlentities($colname, ENT_QUOTES)."</b></th>\n";
}
echo "</tr>\n";
while (($row = oci_fetch_array($s, OCI_ASSOC+OCI_RETURN_NULLS)) != false) {
echo "<tr>\n";
foreach ($row as $item) {
echo " <td>".($item!==null?htmlentities($item,
ENT_QUOTES):" ")."</td>\n";
}
echo "</tr>\n";
}
echo "</table>\n";
?>
This is the error I am receiving when I try to run http://localhost.oci8.php from the browser:
Warning: oci_pconnect(): OCIEnvNlsCreate() failed. There is something
wrong with your system - please check that ORACLE_HOME and
LD_LIBRARY_PATH are set and point to the right directories in
/var/www/html/oci8.php on line 3
Warning: oci_pconnect(): Error while trying to retrieve text for error
ORA-01804 in /var/www/html/oci8.php on line 3
Fatal error: Could not connect to database: in /var/www/html/oci8.php on line 6
___________________________________________________________________
I've been troubleshooting this error for 2 days now. I know it is saying my environments are not set correctly, but I'm at a lost. Here is my .profile.db settings
ORACLE_HOSTNAME=oracle.localdomain; export ORACLE_HOSTNAME
ORACLE_UNQNAME=lionheartdb; export ORACLE_UNQNAME
ORACLE_BASE=/admdba/lionheartdb/oracle; export ORACLE_BASE
ORACLE_HOME=$ORACLE_BASE/product/11.2.0/lionheartdb; export ORACLE_HOME
ORACLE_SID=lionheartdb; export ORACLE_SID
PATH=/usr/sbin:$PATH; export PATH
PATH=$ORACLE_HOME/bin:$PATH; export PATH
LD_LIBRARY_PATH=$ORACLE_HOME/lib; export LD_LIBRARY_PATH
and I also set ORACLE_HOME and LD_LIBRARY_PATH in my /usr/local/apache2/bin/envvars
export LD_LIBRARY_PATH=$ORACLE_HOME/lib; export LD_LIBRARY_PATH
export ORACLE_HOME=$ORACLE_BASE/product/11.2.0/lionheartdb; export ORACLE_HOME
when i go to http://localhost.phpinfo.php to see the values set there this is what I'm shown
oci8
OCI8 Support enabled
Version 1.4.9
Revision $Id: e2241cffb72c940cb2ca267b7a6a0ce436de7e5e $
Active Persistent Connections 0
Active Connections 0
Oracle Run-time Client Library Version 11.2.0.1.0
Oracle Version 11.2
Compile-time ORACLE_HOME /admdba/lionheartdb/oracle/product/11.2.0/lionheartdb
Libraries Used -Wl,-rpath,/admdba/lionheartdb/oracle/product/11.2.0/lionheartdb/lib
-L/admdba/lionheartdb/oracle/product/11.2.0/lionheartdb/lib -lclntsh
Temporary Lob support enabled
Collections support enabled
I have no clue where to go from here, do you see anything I missed? Can you point me in the right direction? Thanks
I'm trying to connect to my database.
Here is the php code I'm using to test the connection first in /var/www/html/oci8.php
<?php
$c = oci_pconnect("hr", "welcome", "lionheartdb");
if (!$c) {
$e = oci_error();
trigger_error('Could not connect to database: '. $e['message'],E_USER_ERROR);
}
$s = oci_parse($c, "select city from locations order by city");
if (!$s) {
$e = oci_error($c);
trigger_error('Could not parse statement: '. $e['message'], E_USER_ERROR);
}
$r = oci_execute($s);
if (!$r) {
$e = oci_error($s);
trigger_error('Could not execute statement: '. $e['message'], E_USER_ERROR);
}
echo "<table border='1'>\n";
$ncols = oci_num_fields($s);
echo "<tr>\n";
for ($i = 1; $i <= $ncols; ++$i) {
$colname = oci_field_name($s, $i);
echo " <th><b>".htmlentities($colname, ENT_QUOTES)."</b></th>\n";
}
echo "</tr>\n";
while (($row = oci_fetch_array($s, OCI_ASSOC+OCI_RETURN_NULLS)) != false) {
echo "<tr>\n";
foreach ($row as $item) {
echo " <td>".($item!==null?htmlentities($item,
ENT_QUOTES):" ")."</td>\n";
}
echo "</tr>\n";
}
echo "</table>\n";
?>
This is the error I am receiving when I try to run http://localhost.oci8.php from the browser:
Warning: oci_pconnect(): OCIEnvNlsCreate() failed. There is something
wrong with your system - please check that ORACLE_HOME and
LD_LIBRARY_PATH are set and point to the right directories in
/var/www/html/oci8.php on line 3
Warning: oci_pconnect(): Error while trying to retrieve text for error
ORA-01804 in /var/www/html/oci8.php on line 3
Fatal error: Could not connect to database: in /var/www/html/oci8.php on line 6
___________________________________________________________________
I've been troubleshooting this error for 2 days now. I know it is saying my environments are not set correctly, but I'm at a lost. Here is my .profile.db settings
ORACLE_HOSTNAME=oracle.localdomain; export ORACLE_HOSTNAME
ORACLE_UNQNAME=lionheartdb; export ORACLE_UNQNAME
ORACLE_BASE=/admdba/lionheartdb/oracle; export ORACLE_BASE
ORACLE_HOME=$ORACLE_BASE/product/11.2.0/lionheartdb; export ORACLE_HOME
ORACLE_SID=lionheartdb; export ORACLE_SID
PATH=/usr/sbin:$PATH; export PATH
PATH=$ORACLE_HOME/bin:$PATH; export PATH
LD_LIBRARY_PATH=$ORACLE_HOME/lib; export LD_LIBRARY_PATH
and I also set ORACLE_HOME and LD_LIBRARY_PATH in my /usr/local/apache2/bin/envvars
export LD_LIBRARY_PATH=$ORACLE_HOME/lib; export LD_LIBRARY_PATH
export ORACLE_HOME=$ORACLE_BASE/product/11.2.0/lionheartdb; export ORACLE_HOME
when i go to http://localhost.phpinfo.php to see the values set there this is what I'm shown
oci8
OCI8 Support enabled
Version 1.4.9
Revision $Id: e2241cffb72c940cb2ca267b7a6a0ce436de7e5e $
Active Persistent Connections 0
Active Connections 0
Oracle Run-time Client Library Version 11.2.0.1.0
Oracle Version 11.2
Compile-time ORACLE_HOME /admdba/lionheartdb/oracle/product/11.2.0/lionheartdb
Libraries Used -Wl,-rpath,/admdba/lionheartdb/oracle/product/11.2.0/lionheartdb/lib
-L/admdba/lionheartdb/oracle/product/11.2.0/lionheartdb/lib -lclntsh
Temporary Lob support enabled
Collections support enabled
I have no clue where to go from here, do you see anything I missed? Can you point me in the right direction? Thanks
Answers
-
Can you review/confirm what you have set in envvars?
What you pasted uses ORACLE_HOME before it is set. Also it uses but never sets ORACLE_BASE. -
/usr/local/apache2/bin/envvars
export LD_LIBRARY_PATH=$ORACLE_HOME/lib; export LD_LIBRARY_PATH
export ORACLE_HOME=$ORACLE_BASE/product/11.2.0/lionheartdb; export ORACLE_HOME
I'm not sure what you meant by
"What you pasted uses ORACLE_HOME before it is set."
Thanks for responding. -
Try something like:
ORACLE_BASE=/admdba/lionheartdb/oracle
export ORACLE_BASE
ORACLE_HOME=$ORACLE_BASE/product/11.2.0/lionheartdb
export ORACLE_HOME
LD_LIBRARY_PATH=$ORACLE_HOME/lib:$LD_LIBRARY_PATH
export LD_LIBRARY_PATH -
Thanks so much that did it, lol. On to another error but hey I'm making progress. Thank you!
This discussion has been closed.