Asked  7 Months ago    Answers:  5   Viewed   42 times

How do I connect to an Oracle database from PHP?

 Answers

43

Forth link in google after searching for your exact questions brought up the following link: http://me2learn.wordpress.com/2008/10/18/connect-php-with-oracle-database/

<?php
    $db = "(DESCRIPTION=(ADDRESS_LIST = (ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.1.34)(PORT = 1521)))(CONNECT_DATA=(SID=orcl)))" ;

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

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

;extension=php_oci8.dll

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

EDIT:

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
 
Pointy
answered 3 Months ago
100

Try following connection string

string con = "Data Source=(DESCRIPTION =(ADDRESS_LIST=(ADDRESS=(PROTOCOL=TCP)(HOST = 000.00.0.00)(PORT = 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
 
Simmeringc
answered 2 Months ago
28

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
 
user2999861
answered 2 Months ago
24

On the Instant Client download page, the next line after the download link for instantclient-basic-nt-12.2.0.1.0.zip 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 :
 
Share