5Answers
  • 3
name

A PHP Error was encountered

Severity: Notice

Message: Undefined index: userid

Filename: views/question.php

Line Number: 191

Backtrace:

File: /home/prodcxja/public_html/questions/application/views/question.php
Line: 191
Function: _error_handler

File: /home/prodcxja/public_html/questions/application/controllers/Questions.php
Line: 433
Function: view

File: /home/prodcxja/public_html/questions/index.php
Line: 315
Function: require_once

name Punditsdkoslkdosdkoskdo

Connecting to Oracle using PHP

How do I connect to a remote Oracle database instance from PHP?

I need to query (read only) the remote Oracle database for some information; do I need to have an Oracle Instant Client installed?

Is the OCI extension for PHP enough?

The best manual for using PHP with Oracle is Underground PHP Oracle Manual. Periodically updated. For example last update describe new cool OCI (Oracle Call Interface) features. I found it by accident and since then has never regretted. Start from that good manual.

  • 4
Reply Report

there are a couple of steps you need to go through to make this work.

First, you need to install the oracle driver for whatever OS you have. Then, create a DSN for odbc to use to connect the php function call to the oracle database. On windows, you can find this on the Control Panel -> ODBC Sources

Once you have done this, restart the DB, the web server and then you should be able to test it all with this:

odbc_connect($dsn,$user,$pass);

If you have linux, the same steps are needed but I'm not sure how you create a DSN in unix.

  • 2
Reply Report
      • 2
    • This will also work, the difference is only that I would connect via DSN instead of using PHP's Oracle extension. Thank you!

If you're attempting to connect to oracle on ubuntu with PHP, the following links have been more than helpful:

A) http://pecl.php.net/bugs/bug.php?id=9253

That's the real-workhorse one - it gives you just about all the data you need.

B) http://fabrizioballiano.net/2008/01/26/how-to-install-php-pdo_oci-on-ubuntu-gutsy/

This is also helpful for details of things that need to be installed for oracle to work with ubuntu.

If you're using it with PHP, you'll need to make sure that the TNS_ADMIN and ORACLE_HOME environment variables are available for apache's user - there's a file named 'envvars' in the apache2 directory where you can set these. (For my own ease of use, I have the two point to the same directory.)

  • 1
Reply Report

Warm tip !!!

This article is reproduced from Stack Exchange / Stack Overflow, please click

Trending Tags

Related Questions