i m suffering with the following error
Warning: oci_connect() [function.oci-connect]: ORA-01017: invalid username/password; logon denied in C:\wamp\www\New Folder\connection.php on line 4

but i've tried atleast 100 times, username and passwords both r correct

$conn=oci_connect("sysdba", "hammad90", "");
is thr any problem in the above code?

Dani AI

Generated

This error almost always means the Oracle server rejected the credentials or the client hit the wrong database instance. In this thread saw ORA-01017 and — as and suggested — supplying the database/service (the third oci_connect parameter) fixed the problem. The third parameter tells the Oracle client exactly which SID/service or TNS alias to reach; if you omit it PHP/OCI will fall back to ORACLE_SID, TWO_TASK or other environment defaults which are often not set under WAMP. (php.net)

A frequent root cause to watch for is confusing the SYS user and the SYSDBA role: SYSDBA is a privileged connect mode, not a username. To connect with SYSDBA from OCI8 you must use a real username (typically SYS or another account granted SYSDBA) and request the privileged session mode (for example OCI_SYSDBA), and enable oci8.privileged_connect in php.ini on the PHP/Apache side. If you do not need SYS-level rights, connect with a normal schema user and an explicit service name. (php.net)

Quick checklist to finish troubleshooting:

  • Verify the same credentials from the web server host with SQL*Plus (confirms listener/TNS and password).
  • Check SEC_CASE_SENSITIVE_LOGON (Oracle 11g+ makes passwords case sensitive) and whether the account is locked/expired.
  • Make the connection string explicit (Easy Connect host:port/service, or a TNS alias and correct TNS_ADMIN).
  • Avoid silencing errors; use oci_error() after oci_connect() to get the full Oracle message for diagnosis.

These steps cover the usual causes you will hit after the fix suggested by and . (php.net)

Recommended Answers

All 3 Replies

you must pass database name also

$conn=oci_connect("sysdba", "hammad90", $databasename);

i m suffering with the following error
Warning: oci_connect() [function.oci-connect]: ORA-01017: invalid username/password; logon denied in C:\wamp\www\New Folder\connection.php on line 4

but i've tried atleast 100 times, username and passwords both r correct

$conn=oci_connect("sysdba", "hammad90", "");
is thr any problem in the above code?

Try providing the dbname as a third parameter, it will suppress any errors.

if (isset($this->_config['dbname'])) {
            $this->_connection = @oci_connect(
                $this->_config['username'],
                $this->_config['password'],
                $this->_config['dbname']);
        } else {
            $this->_connection = oci_connect(
                $this->_config['username'],
                $this->_config['password']);
        }

thanx. it worked :)

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.