First of all you need to check whether “oci8” support is enabled or not, if not you have to enable that you can check this in your phpinfo file.

Once this is done.

Now in you test.php file

You have to explicitly set the ORACLE_HOME and LD_LIBRARY_PATH path.
This information will be available in you phpinfo file.

The “$dbstr” variable information you can find it from your “tnsnames.ora” file .

Test.php start

—————————————————————————————–

if (!ini_get(‘display_errors’)) {
ini_set(‘display_errors’, 1);
}
PutEnv(“ORACLE_HOME=/usr/lib/oracle/xe/app/oracle/product/10.2.0/server/”);
PutEnv(“LD_LIBRARY_PATH=-Wl,-rpath,/usr/lib/oracle/xe/app/oracle/product/10.2.0/server//lib -L/usr/lib/oracle/xe/app/oracle/product/10.2.0/server//lib -lclntsh”);

$dbstr =”(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.0.XX)(PORT = 1521))
(CONNECT_DATA =
(SERVER = DEDICATED)
(SERVICE_NAME = YOURDATABASENAME)
)
)”;

if(!@($conn = oci_connect(‘DBUSERNAME’,’DBPASSWORD’,$dbstr)))
{
print_r(ocierror());

}
else
{
echo “connected succesfully”;
}

—————————————————————————————–

Thanks

Related Post

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.