请问PDO为什么连接不上oracle
数据库环境Oracle 11g 64位 window server 2003
PHP环境:32位php,运行在windows XP上。
01.
02.try {
03.
04. $dbh = new PDO('oci:dbname=//172.30.1.39:1521/orcl;charset=utf8', 'scott','neusoft');
05.
06. foreach($dbh->query('SELECT * from test') as $row) {
07. print_r($row);
08. print("
");
09. }
10. $dbh = null;
11.} catch (PDOException $e) {
12. print "Error!: " . $e->getMessage() . "
";
13. die();
14.}
15.?>
错误:
01.Error!: SQLSTATE[HY000]: OCIEnvNlsCreate: Check the character set is valid and that PHP has access to Oracle libraries and NLS data (ext\pdo_oci\oci_driver.c:558)
如果修改成
01.
02.try {
03.
04. $dbh = new PDO('oci:dbname=//172.30.1.39:1521/orcl', 'scott','neusoft');
05.
06. foreach($dbh->query('SELECT * from test') as $row) {
07. print_r($row);
08. print("
");
09. }
10. $dbh = null;
11.} catch (PDOException $e) {
12. print "Error!: " . $e->getMessage() . "
";
13. die();
14.}
15.?>
则报错:
01.Error!: SQLSTATE[]: pdo_oci_handle_factory: (ext\pdo_oci\oci_driver.c:579)
------解决方案--------------------检查tnsnames.ora,listener.ora中,sqlnet.ora中,日志文件看看
------解决方案--------------------前者是字符集名称错了
关键在于后者,你的 oci 版本是否低于 oracle 版本?
Stellungnahme:Der Inhalt dieses Artikels wird freiwillig von Internetnutzern beigesteuert und das Urheberrecht liegt beim ursprünglichen Autor. Diese Website übernimmt keine entsprechende rechtliche Verantwortung. Wenn Sie Inhalte finden, bei denen der Verdacht eines Plagiats oder einer Rechtsverletzung besteht, wenden Sie sich bitte an admin@php.cn