ORA-12705:无法访问NLS数据文件或指定的无效环境(ext \ pdo_oci \ oci_driver.c:686)

时间:2014-09-16 13:54:36

标签: php oracle pdo

我确实设置了Apache和PHP,当我尝试通过PDO连接时,我得到了这条消息 我正在使用oracle 10g企业管理。

OCISessionBegin: ORA-12705: Cannot access NLS data files or invalid environment specified  (ext\pdo_oci\oci_driver.c:686)

这就是我试图建立oracle连接的方式

$tns = "
(DESCRIPTION =
    (ADDRESS_LIST =
      (ADDRESS = (PROTOCOL = TCP)(HOST = COD3R-PC)(PORT = 1521))
    )
    (CONNECT_DATA =
      (SERVICE_NAME = opera)
    )
  )
       ";
try {
    $conn = new PDO("oci:dbname=".$tns, 'customsearch', 'babaji');
    $conn->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
} catch(PDOException $e) {
    echo 'ERROR: ' . $e->getMessage();
}

1 个答案:

答案 0 :(得分:0)

putenv("NLS_LANG=.WE8ISO8859P1");
$tns = "
(DESCRIPTION =
    (ADDRESS_LIST =
      (ADDRESS = (PROTOCOL = TCP)(HOST = COD3R-PC)(PORT = 1521))
    )
    (CONNECT_DATA =
      (SID = I_DONT_KNOW_YOUR_SID)
      (SERVER = DEDICATED)
    )
  )
       ";
try {
    $conn = new PDO("oci:dbname=".$tns, 'customsearch', 'babaji');
    $conn->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
} catch(PDOException $e) {
    echo 'ERROR: ' . $e->getMessage();

}