phporacle-databaseora-01017

PHP 5 connecting to Oracle 9.2


I'm have difficulty connecting from PHP5 to 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. I've setup a test db connection script as follows:

PHP Code:

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] => 
)

Solution

  • 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.

    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.

    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. 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. 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". But this is an Oracle product, and it's displaying an Oracle error code, so that's a long shot.