# ASP and PHP connection to ORACLE

**URL:** <https://forum.kirupa.com/t/asp-and-php-connection-to-oracle/185886>\
**Category:** programming\
**Created:** [April 17, 2006, 1:34pm UTC](https://forum.kirupa.com/t/asp-and-php-connection-to-oracle/185886 "2006-04-17T13:34:32Z")\
**Posts on this page:** 10\
**Page:** 1

<div class="post-metadata">

**Author:** ![KaiLok](https://avatars.discourse-cdn.com/v4/letter/k/7bcc69/32.png) [@KaiLok](https://forum.kirupa.com/u/KaiLok)\
**Post date:** [April 17, 2006, 1:34pm UTC](https://forum.kirupa.com/t/asp-and-php-connection-to-oracle/185886/1 "2006-04-17T13:34:32Z")

</div>

I am trying to connect to Oracle database.  
Howevery i found it difficult as i don’t know what to type for:

For ASP:

Server.CreateObject("[COLOR=red]ADODB.Connection[/COLOR]")

and

conn.Open “[COLOR=red]Driver={Microsoft Access Driver (\*.mdb)};” & \_  
“DBQ=” & MyPath[/COLOR]

FOR php:

$link = mysql\_connect([COLOR=red]dbhost[/COLOR], dbuser, dbpassword)

[COLOR=red]$desiredContent = mysql\_fetch\_array($result, MYSQL\_ASSOC);[/COLOR]  
[COLOR=red]mysql\_free\_result($result);[/COLOR]

What are them respectively and what should i type to connect to oracle??

Which of them are easier to implement???

:puzzled:

---

<div class="post-metadata">

**Author:** ![Seb\_Hughes](https://avatars.discourse-cdn.com/v4/letter/s/839c29/32.png) [@Seb\_Hughes](https://forum.kirupa.com/u/Seb_Hughes)\
**Post date:** [April 17, 2006, 1:44pm UTC](https://forum.kirupa.com/t/asp-and-php-connection-to-oracle/185886/2 "2006-04-17T13:44:17Z")

</div>

You do know you have to pay for Oracel database’s. Why not use MySQL?

---

<div class="post-metadata">

**Author:** ![KaiLok](https://avatars.discourse-cdn.com/v4/letter/k/7bcc69/32.png) [@KaiLok](https://forum.kirupa.com/u/KaiLok)\
**Post date:** [April 17, 2006, 1:48pm UTC](https://forum.kirupa.com/t/asp-and-php-connection-to-oracle/185886/3 "2006-04-17T13:48:12Z")

</div>

Actually i am doing a school project and the university provides me oracle to use. I learnt using servlet to connect the database but i have no idea on using php or asp :diss:

---

<div class="post-metadata">

**Author:** ![Seb\_Hughes](https://avatars.discourse-cdn.com/v4/letter/s/839c29/32.png) [@Seb\_Hughes](https://forum.kirupa.com/u/Seb_Hughes)\
**Post date:** [April 17, 2006, 1:52pm UTC](https://forum.kirupa.com/t/asp-and-php-connection-to-oracle/185886/4 "2006-04-17T13:52:45Z")

</div>

$host = “”;  
$username = “”;  
$password = “”;  
$database = “”;

$connect = mysql\_connect($host, $username, $password);  
$select\_database = mysql\_select\_db($database, $connect);

Dunno id this woks for oracle but works for mysql 😛

---

<div class="post-metadata">

**Author:** ![KaiLok](https://avatars.discourse-cdn.com/v4/letter/k/7bcc69/32.png) [@KaiLok](https://forum.kirupa.com/u/KaiLok)\
**Post date:** [April 17, 2006, 2:00pm UTC](https://forum.kirupa.com/t/asp-and-php-connection-to-oracle/185886/5 "2006-04-17T14:00:58Z")

</div>

😏 yup~~  
But it gave me hard time in think about the $host of oracle. And i don’t have to choose a database to use Oracle too.

Its confusing.

---

<div class="post-metadata">

**Author:** ![hl1](https://yyz1.discourse-cdn.com/flex011/user_avatar/forum.kirupa.com/hl1/32/849_2.png) [@hl1](https://forum.kirupa.com/u/hl1)\
**Post date:** [April 17, 2006, 3:15pm UTC](https://forum.kirupa.com/t/asp-and-php-connection-to-oracle/185886/6 "2006-04-17T15:15:50Z")

</div>

I believe it’s actually [odbc\_connect()](http://us2.php.net/manual/en/function.odbc-connect.php) for PHP. I don’t have any personal experience with Oracle, however I’ve looked a bit into it.

odbc\_autocommit – Toggle autocommit behaviour  
odbc\_binmode – Handling of binary column data  
odbc\_close\_all – Close all ODBC connections  
odbc\_close – Close an ODBC connection  
odbc\_columnprivileges – Returns a result identifier that can be used to fetch a list of columns and associated privileges  
odbc\_columns – Lists the column names in specified tables  
odbc\_commit – Commit an ODBC transaction  
odbc\_connect – Connect to a datasource  
odbc\_cursor – Get cursorname  
odbc\_data\_source – Returns information about a current connection  
odbc\_do – Synonym for odbc\_exec()  
odbc\_error – Get the last error code  
odbc\_errormsg – Get the last error message  
odbc\_exec – Prepare and execute a SQL statement  
odbc\_execute – Execute a prepared statement  
odbc\_fetch\_array – Fetch a result row as an associative array  
odbc\_fetch\_into – Fetch one result row into array  
odbc\_fetch\_object – Fetch a result row as an object  
odbc\_fetch\_row – Fetch a row  
odbc\_field\_len – Get the length (precision) of a field  
odbc\_field\_name – Get the columnname  
odbc\_field\_num – Return column number  
odbc\_field\_precision – Synonym for odbc\_field\_len()  
odbc\_field\_scale – Get the scale of a field  
odbc\_field\_type – Datatype of a field  
odbc\_foreignkeys – Returns a list of foreign keys in the specified table or a list of foreign keys in other tables that refer to the primary key in the specified table  
odbc\_free\_result – Free resources associated with a result  
odbc\_gettypeinfo – Returns a result identifier containing information about data types supported by the data source  
odbc\_longreadlen – Handling of LONG columns  
odbc\_next\_result – Checks if multiple results are available  
odbc\_num\_fields – Number of columns in a result  
odbc\_num\_rows – Number of rows in a result  
odbc\_pconnect – Open a persistent database connection  
odbc\_prepare – Prepares a statement for execution  
odbc\_primarykeys – Returns a result identifier that can be used to fetch the column names that comprise the primary key for a table  
odbc\_procedurecolumns – Retrieve information about parameters to procedures  
odbc\_procedures – Get the list of procedures stored in a specific data source  
odbc\_result\_all – Print result as HTML table  
odbc\_result – Get result data  
odbc\_rollback – Rollback a transaction  
odbc\_setoption – Adjust ODBC settings  
odbc\_specialcolumns – Returns either the optimal set of columns that uniquely identifies a row in the table or columns that are automatically updated when any value in the row is updated by a transaction  
odbc\_statistics – Retrieve statistics about a table  
odbc\_tableprivileges – Lists tables and the privileges associated with each table  
odbc\_tables – Get the list of table names stored in a specific data source

~PHP manual OBDC function table of contents.

---

<div class="post-metadata">

**Author:** ![955](https://avatars.discourse-cdn.com/v4/letter/9/4bbf92/32.png) [@955](https://forum.kirupa.com/u/955)\
**Post date:** [April 17, 2006, 5:15pm UTC](https://forum.kirupa.com/t/asp-and-php-connection-to-oracle/185886/7 "2006-04-17T17:15:55Z")

</div>

Actually, it’s probably the [OCI8](http://us2.php.net/manual/en/ref.oci8.php) extension you want to use 😉

---

<div class="post-metadata">

**Author:** ![SlowRoasted](https://avatars.discourse-cdn.com/v4/letter/s/a698b9/32.png) [@SlowRoasted](https://forum.kirupa.com/u/SlowRoasted)\
**Post date:** [April 17, 2006, 6:03pm UTC](https://forum.kirupa.com/t/asp-and-php-connection-to-oracle/185886/8 "2006-04-17T18:03:38Z")

</div>

Yeah and if you use odbc you are going to have to go into the server admin tools and specify the database you are going to use, if you are using a windows based machine, not sure about linux.

---

<div class="post-metadata">

**Author:** ![teiz77](https://yyz1.discourse-cdn.com/flex011/user_avatar/forum.kirupa.com/teiz77/32/771_2.png) [@teiz77](https://forum.kirupa.com/u/teiz77)\
**Post date:** [April 18, 2006, 7:17am UTC](https://forum.kirupa.com/t/asp-and-php-connection-to-oracle/185886/9 "2006-04-18T07:17:00Z")

</div>

you might wanna look into [adodb](http://adodb.sourceforge.net/). ADOdb is a database abstraction library for PHP. It also supports Oracle.

---

<div class="post-metadata">

**Author:** ![ironikart](https://avatars.discourse-cdn.com/v4/letter/i/7feea3/32.png) [@ironikart](https://forum.kirupa.com/u/ironikart)\
**Post date:** [April 19, 2006, 2:45am UTC](https://forum.kirupa.com/t/asp-and-php-connection-to-oracle/185886/10 "2006-04-19T02:45:52Z")

</div>

Ditto on ADOdb (or PEAR::DB) - there is a bit of pain in connecting and talking to an oracle DB using base PHP functions.
