Asked  7 Months ago    Answers:  5   Viewed   42 times

How do I connect to an Oracle database from PHP?



Forth link in google after searching for your exact questions brought up the following link:


    if($c = OCILogon("system", "your database password", $db))
        echo "Successfully connected to Oracle.n";
        $err = OCIError();
        echo "Connection failed." . $err[text];
Wednesday, March 31, 2021
answered 7 Months ago

After a quick search I found this page. If you don't have the oracle extension enabled in your php.ini then the constant is undefined. Try searching for the line


in your php.ini and remove the semicolon to uncomment it. Then, restart Apache to load the module and see if it connects.


Try dumping the php.ini variables by doing something like print_r(ini_get_all()) and see what is set and what isn't. You may be using a different php.ini for the command line.

Wednesday, August 18, 2021
answered 3 Months ago

Try following connection string

string con = "Data Source=(DESCRIPTION =(ADDRESS_LIST=(ADDRESS=(PROTOCOL=TCP)(HOST = = 0000)))(CONNECT_DATA =(SERVICE_NAME = database)));User ID=User/Schema;Password=password;Unicode=True";

& then use this conection string as follow

using (OracleConnection objConn = new OracleConnection(con))
   \ code
Sunday, August 22, 2021
answered 2 Months ago

How was the database exported?

  • If it was exported using exp and a full schema was exported, then

    1. Create the user:

      create user <username> identified by <password> default tablespace <tablespacename> quota unlimited on <tablespacename>;
    2. Grant the rights:

      grant connect, create session, imp_full_database to <username>;
    3. Start the import with imp:

      imp <username>/<password>@<hostname> file=<filename>.dmp log=<filename>.log full=y;
  • If it was exported using expdp, then start the import with impdp:

    impdp <username>/<password> directory=<directoryname> dumpfile=<filename>.dmp logfile=<filename>.log full=y;

Looking at the error log, it seems you have not specified the directory, so Oracle tries to find the dmp file in the default directory (i.e., E:appVensiadminoratestdpdump).

Either move the export file to the above path or create a directory object to pointing to the path where the dmp file is present and pass the object name to the impdp command above.

Friday, September 3, 2021
answered 2 Months ago

On the Instant Client download page, the next line after the download link for states:

The 12.2 Basic package requires the Microsoft Visual Studio 2013 Redistributable.

As you haven't listed that in what you've tried, installing it should be your next step.

You should also reboot to ensure that your changes to the environment PATH are applied system wide (e.g. to the Apache service).

Tuesday, October 19, 2021
Narendra Chitrakar
answered 1 Week ago
Only authorized users can answer the question. Please sign in first, or register a free account.
Not the answer you're looking for? Browse other questions tagged :