【发布时间】:2013-10-21 10:59:52
【问题描述】:
我正在开发一个连接到 Oracle 数据库的 PHP API,但不幸的是连接不起作用。首先,我实现了开发环境(oracle数据库服务器+apache服务器),一切都配置好了,我猜。问题是我写的代码没有得到任何响应,即使我输入了错误的数据。
PHP 信息 oci8:
[rvieira@localhost ~]$ php --ri oci8
oci8
OCI8 Support => enabled
Version => 1.4.10
Revision => $Id: 44bfa713983a99b3e59477f6532e5fb51b6dee94 $
Active Persistent Connections => 0
Active Connections => 0
Oracle Run-time Client Library Version => 11.2.0.2.0
Oracle Instant Client Version => 11.2
Temporary Lob support => enabled
Collections support => enabled
Directive => Local Value => Master Value
oci8.max_persistent => -1 => -1
oci8.persistent_timeout => -1 => -1
oci8.ping_interval => 60 => 60
oci8.privileged_connect => Off => Off
oci8.statement_cache_size => 20 => 20
oci8.default_prefetch => 100 => 100
oci8.old_oci_close_semantics => Off => Off
oci8.connection_class => no value => no value
oci8.events => Off => Off
PHP 代码:
<?php
$connection = oci_connect('sys', 'rvieira', 'localhost/xe');
if (!$connection) {
$m = oci_error();
echo $m['message'], "\n";
exit;
}
else {
print "Connected to Oracle!";
}
?>
我也把配置开发环境的教程放在这里:
【问题讨论】:
-
您查看过服务器日志吗?他们应该告诉你发生了什么。
-
好吧,我决定通过 CLI 运行 php 文件,它运行并工作,但是,在浏览器中不起作用。 :| alojaimagens.com/images/9grkq2kylfgaaiksbd.png
-
Mike W 这里是:[Sun Oct 13 23:24:55 2013] [error] [client 127.0.0.1] PHP Warning: oci_connect(): Error while trying to retrieve text for error ORA -01804\n 在 /var/www/html/api.php 第 2 行 [Sun Oct 13 23:25:12 2013] [error] [client 127.0.0.1] PHP 警告:oci_connect(): OCIEnvNlsCreate() 失败。您的系统有问题 - 请检查 LD_LIBRARY_PATH 是否在第 2 行的 /var/www/html/api.php 中包含带有 Oracle Instant Client 库的目录
标签: php database oracle connection oci8