Page 1 of 1
oracle connectivity with php
Posted: Tue Aug 11, 2009 4:20 am
by yasir_memon
can any one please tell me the simple coding for connecting oracle database??
waiting for ur replies
thanks in advance
Re: oracle connectivity with php
Posted: Tue Aug 11, 2009 4:33 am
by turbolemon
You could use Oracle's OCI module, or PDO_OCI:
http://uk.php.net/oci8
http://us.php.net/manual/en/ref.pdo-oci.php
From the Oracle wiki:
Re: oracle connectivity with php
Posted: Tue Aug 11, 2009 5:30 am
by yasir_memon
thx for ur repy when i am using this code this error is occured "could not find driver" can u please tell me why this is happening
thanks
Re: oracle connectivity with php
Posted: Tue Aug 11, 2009 5:38 am
by turbolemon
You need the OCI driver module installed in PHP. This means that you need to have install the oracle "instant client" binary on your server system. Then you need to install the php module, which is really easy if you have PEAR.
http://ubuntuforums.org/archive/index.php/t-92528.html
This link describes how to install OCI / Instant Client on Ubuntu/Debian systems, though the post is quite old! It just depends on your access to the server config and operating system really.
Re: oracle connectivity with php
Posted: Tue Aug 11, 2009 6:54 am
by yasir_memon
i am still facing problems can u please tell me the steps how to connect with oracle database i am using windows server 2003 and wamp software
waiting for ur replies
thanks
Re: oracle connectivity with php
Posted: Tue Aug 11, 2009 7:05 am
by turbolemon
I have never personally undertaken the task, certainly not under windows. Try calling phpinfo() to check if the OCI8 module is already installed, and if so you just need to install
http://www.oracle.com/technology/softwa ... index.html for your platform.
This is the official walk-through, should be fairly straight forward
http://www.oracle.com/technology/pub/no ... stant.html. Instead of going away and installing a fresh Apache/PHP you should be able to go ahead and modify your existing installation, adding the DLL to the relevant directory and adding the line to php.ini to load the module.
Thats the best I can offer!
Re: oracle connectivity with php
Posted: Wed Aug 12, 2009 5:13 am
by yasir_memon
i want to connect with oracle data base when im using this code i am facing this error
could not find driver
$tns = "
(DESCRIPTION =
(ADDRESS_LIST =
(ADDRESS = (PROTOCOL = TCP)(HOST = 172.16.0.2)(PORT = 1521))
)
(CONNECT_DATA =
(SERVICE_NAME = aktmapp)
)
)
";
$db_username = "ERP_TEST";
$db_password = "ERP_TEST";
try{
$conn = new PDO("oci:dbname=".$tns,$db_username,$db_password);
}catch(PDOException $e){
echo ($e->getMessage());
}
and when i am using this code i am facing this error
Fatal error: Call to undefined function oci_connect() in C:\wamp\www\conn.php on line 17
so kindly tell me what type of mistake is there waiting for rplies thx
$tnsName = '(DESCRIPTION =
(ADDRESS_LIST =
(ADDRESS = (PROTOCOL = TCP)(HOST = 172.16.0.2)(PORT = 1521))
)
(CONNECT_DATA =
(SERVICE_NAME = aktmapp)
)
)';
$username = 'ERP_TEST';
$password = 'ERP_TEST';
//$conn=oci_connect()
$conn=oci_connect($username,$password,'//172.16.0.2:1521/XE');
if (!$conn) {
$e = oci_error(); // For oci_connect errors pass no handle
echo '<b><font color="red">FAILED</font></b> : ' . htmlentities($e[
'message']);
} else {
echo '<b><font color="green">OK!</font></b>';
oci_close($conn);