Today,I encountered an issue, that report ORA-12705: Cannot access NLS data files or invalid environme,
I am accessing the oracle database which install in unix ,by php under windowxp. also in my pc, I installed the oracle database due to TOAD, But I prefer to the instantclient to connect to oracle db in unix, so mask the NLS_LANG in regester,
yet It does not work, then add NLS_LANG = AMERICAN_AMERICA.AL32UTF8 in environment, restart pc,
Successfully connect oracle db.
DbPool.php
<?php
# Local Mysql
define("DBLOCUSER", "aaron");
define("DBLOCPWD", "121312");
#new db-machine
define("DBLOCSID", "localhost:3306");
#define("DBLOCSID", "10.40.64.219:3306");
#Suzhou Drive ODS
define("DBUSER", "G341451");
define("DBPWD", "readonly");
define("DBSID", "SUZ_ODS");
# WX Site ODS
define("WXDRUSER", "AMKENG046");
define("WXDRPWD", "janet");
define("WXDRSID", "ODS_WUXI.WORLD");
#Korat Drive ODS
define("KRDRUSER", "PPA");
define("KRDRPWD", "PPAFA2006");
define("KRDRSID", "ODS_KORAT.WORLD");
#UAT COTS_TAB_BENE_ADVICE
define("UATUSER", "RCOBRSR1");
define("UATPWD", "RCOBRSR1");
define("UATSID", "asotr.kemet.com");
class Dbcon{
private $con;
#Get Local MySQL connection
function getConLoc(){
$this->con=@mysql_connect(DBLOCSID,DBLOCUSER,DBLOCPWD);
return $this->con;
}
#Get SZ Drive ODS connection
function getConSZD(){
$this->con=oci_connect(DBUSER,DBPWD,DBSID);
return $this->con;
}
#Get WX Drive ODS connection
function getConWXD(){
$this->con=oci_connect(WXDRUSER,WXDRPWD,WXDRSID);
return $this->con;
}
#Get Korat Drive ODS database connection
function getConKRD(){
$this->con=oci_connect(KRDRUSER,KRDRPWD,KRDRSID);
return $this->con;
}
#Get UAT NCS_CITIBANK connection
function getConUAT(){
$this->con=oci_connect(UATUSER,UATPWD,UATSID);
return $this->con;
}
#Shutdown Oracle Connection
function closeOracle(){
oci_close($this->con);
return 0;
}
#Shutdown MySQL Connection
function closeMysql(){
mysql_close($this->con);
}
}
?>
query.php
<?php
# Generally use as get the family from WX site,Such as 9CC,9CY....
require_once("../include/DbPool.php");
$db=new Dbcon();
$conn=$db->getConUAT();
$sql="SELECT BRANCHNAME from COTS_TAB_BRANCH";
$s=oci_parse($conn,$sql);
oci_execute($s,OCI_DEFAULT);
echo "<table border='1' cellspacing='0' cellpadding='0' align='center'>
<tr><td>No.</td><td>Branch</td>";
$i=0;
while(oci_fetch($s)){
$i++;
echo "<tr><td>".$i."</td><td>".ociresult($s,"BRANCHNAME")."</td></tr>";
}
echo "</table>";
$db->closeOracle();
?>