Connecting to Oracle via php

Last update on July 30, 2009 01:48 PM by jak58
Published by deri58

Connecting to Oracle via php









Settings


Below is an article based on an example of connection to an Oracle database through a php script. However it is not designed to configure your oracle server and oracle client. It ensure that you can access your oracle server from the web server using the SQLPlus.
We can normally connect to a server based on Oracle 8i.

You can find example of codes with other Oracle version on below link:

www.php.net

Requirements


It is essential to assemble PHP with Oracle8i module. Under windows, it is crucial to the php.ini to include the line extension=php_oci8.dll

Example of code


$c1 = ocilogon("scott", "tiger", $db);
$c2 = ocilogon("scott", "tiger", $db);

function create_table($conn) 

  $stmt = ociparse($conn, "create table scott.hallo (test varchar2(64))");
  ociexecute($stmt);
  echo $conn . " created table\n\n";

function drop_table($conn) 

  $stmt = ociparse($conn, "drop table scott.hallo");
  ociexecute($stmt);
  echo $conn . " dropped table\n\n";


function insert_data($conn) 

  $stmt = ociparse($conn, "insert into scott.hallo 
           values('$conn' || ' ' || to_char(sysdate,'DD-MON-YY HH24:MI:SS'))");
  ociexecute($stmt, OCI_DEFAULT);
  echo $conn . " inserted hallo\n\n";



This is one of the easiest way to access Oracle amongst others.
Best answers for « Connecting to Oracle via php » in :
[Video] PC-TV Connection Show[Video] PC-TV Connection It is relatively simple to connect the PC to the TV. Connections It must first connect devices via S-video cable from the PC to the TV, then the sound via the headphone output to TV CINCH input. When the TV has this...
How to connect two computers via cable? ShowHow to connect two computers via cable? You can connect two machines via a crossover cable which is very simple! Step-by-step on how to connect two PC's via cable This describes the procedure to connect a PC with a laptop, which...
How to connect your PC to your TV set ShowHow to connect your PC to your TV set Requirements for your PC Requirements for your TV set Configurations Notes It is possible to connect your PC to your television set to enjoy DivX, FLV or DVD video formats compatible on your...
Download Outlook Connector ShowConnector Microsoft Outlook allows to use Outlook 2003 or Outlook 2007 to access and manage freely your Windows Live Hotmail or Live Mail accounts, especially the contacts. Depending on the services, the calendar task synchronization and the notes...
Sharing an Internet connection ShowAdvantagesIf you have a LAN (two computers or more connected in a network), of which one is connected to the Internet (via a DSL modem, cable, etc.), it may be worthwhile to make the Internet accessible to the other computers on the LAN by installing...
Sharing an Internet connection ShowAdvantages If you have a local area network (two or more computers connected in a network) with one computer connected to the Internet (via a modem, using a cable, etc.), it may be useful to make the connection accessible to the other computers on...