简体   繁体   English

PHP 5连接到Oracle 9.2

[英]PHP 5 connecting to Oracle 9.2

I'm have difficulty connecting from PHP5 to Oracle 9.2. 我很难从PHP5连接到Oracle 9.2。 I've tried both 1.4.2 and 1.4.5 of OCI and I am able to connect to Oracle 10g and up. 我已经尝试了OCI的1.4.2和1.4.5,并且能够连接到Oracle 10g及更高版本。 I've setup a test db connection script as follows: 我已经设置了一个测试数据库连接脚本,如下所示:

PHP Code: PHP代码:

echo "Testing Connection...";
ociinternaldebug(1);
$conn = oci_new_connect('someuser', 'somepassword', '(DESCRIPTION = (ADDRESS = (PROTOCOL = TCP)(HOST = 172.0.0.2 )(PORT = 1521)) (CONNECT_DATA = (SID = ORCL)))');

if (!$conn) {
    $e = oci_error();
    print_r ($e);
}
else
{
    echo('Successful');
}

I get this error: 我收到此错误:

OCI8 DEBUG: OCINlsEnvironmentVariableGet at (ext\oci8\oci8.c:1826) 
OCI8 DEBUG L1: using shared pool: (0x2078b68) at (ext\oci8\oci8.c:3028) 
OCI8 DEBUG: OCIHandleAlloc at (ext\oci8\oci8.c:3039) 
OCI8 DEBUG: OCIHandleAlloc at (ext\oci8\oci8.c:3049) 
OCI8 DEBUG: OCIAttrGet at (ext\oci8\oci8.c:3082) 
OCI8 DEBUG: OCIAttrGet at (ext\oci8\oci8.c:3083) 
OCI8 DEBUG L1: (numopen=0)(numbusy=0) at (ext\oci8\oci8.c:3085) 
OCI8 DEBUG: OCISessionGet at (ext\oci8\oci8.c:3096) 
OCI8 DEBUG: OCIErrorGet at (ext\oci8\oci8.c:1632) 
OCI8 DEBUG: OCIHandleFree at (ext\oci8\oci8.c:2218) 
OCI8 DEBUG: OCIHandleFree at (ext\oci8\oci8.c:2221) 
OCI8 DEBUG: OCIErrorGet at (ext\oci8\oci8.c:1632) 
Array
(
    [code] => 1017
    [message] => **ORA-01017: invalid username/password; logon denied**
    [offset] => 0
    [sqltext] => 
)

您可以使用sqlplus从同一台机器/使用相同的用户名/密码登录到同一数据库吗?

Is it possible your password has some character set issues? 您的密码是否可能存在一些字符集问题? Is there a character in there that is not supported by one of your clients or servers? 客户端或服务器之一不支持该字符吗? Mabye PHP incorrectly converts the characters, or maybe they are incorrectly converted whenever you use SQL*Plus, and the "correct" version sent by PHP appears wrong to the server. Mabye PHP错误地转换了字符,或者每当您使用SQL * Plus时它们都可能被错误地转换,并且PHP发送的“正确”版本对服务器而言是错误的。

Run this query to see what the server is actually doing. 运行此查询以查看服务器实际在做什么。 If the return code is 1017 then the server is getting the wrong username or password. 如果返回码为1017,则服务器输入的用户名或密码错误。

select userid, userhost, terminal, returncode, ntimestamp#
from sys.aud$
order by ntimestamp# desc;

I don't think I've ever seen an Oracle error message lie. 我认为我从未见过Oracle错误消息所在。 But I have seen some programs misinterpret the error messages. 但是我看到一些程序会误解错误消息。 For example, if your password is expired but you've got a grace period Oracle will return an error but still allow you to login. 例如,如果您的密码已过期但有宽限期,则Oracle将返回错误,但仍允许您登录。 SQL*Plus will warn "ORA-28002: the password will expire within 8 days", but some programs will incorrectly interpret this as a login failure and may even say "bad username/password". SQL * Plus将警告“ ORA-28002:密码将在8天内过期”,但是某些程序会错误地将此解释为登录失败,甚至可能会说“用户名/密码错误”。 But this is an Oracle product, and it's displaying an Oracle error code, so that's a long shot. 但这是一个Oracle产品,它显示一个Oracle错误代码,因此很远。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM