Jump to content

Php - Oracle connection


inka

Recommended Posts

Hello.

 

I am trying to connect my php page to an Oracle database, without success until now.

I tried everything I could find on google, but nothing....

 

We have enabled oci8 in php:

oci8
OCI8 Support enabled
Version 1.4.7
Revision $Id: bf2eaf558b050b6d2e6d098bed6345af7e842ea4 $
Active Persistent Connections 0
Active Connections 0
Oracle Run-time Client Library Version 11.2.0.3.0
Oracle Instant Client Version 11.2
Temporary Lob support enabled
Collections support enabled
Directive Local Value Master Value
oci8.connection_class no value no value
oci8.default_prefetch 100 100
oci8.events Off Off
oci8.max_persistent -1 -1
oci8.old_oci_close_semantics Off Off
oci8.persistent_timeout -1 -1
oci8.ping_interval 60 60
oci8.privileged_connect Off Off
oci8.statement_cache_size 20 20

 

I tried the following connection attempts - 3 versions (the server is not on the same machine as the oracle db):

<?php

//Putenv("NLS_LANG=SPANISH_SPAIN.WE8ISO8859P15");
$db="(DESCRIPTION=
 (ADDRESS_LIST=
 (ADDRESS=(PROTOCOL=TCP)
	 (HOST=$GLOBALS[192.168.1.102])(PORT=$GLOBALS[1521])
 )
 )
 (CONNECT_DATA=(SID=$GLOBALS[***]))
)";
$conn = OCILogon($GLOBALS['user'],$GLOBALS['pass'],$db);

if (!conn)
{
$e=oci_error();
trigger_error(htmlentities($e['message'], ENT_QUOTES), E_USER_ERROR);
echo $e;
echo "dfsdf<br />";
return FALSE;
}
else
echo "success";
return $conn;
}
/*
$db='(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.1.102)(PORT = 1521))
(CONNECT_DATA =
(SERVER = DEDICATED)
(SERVICE_NAME = ***)
)
)';
$connection = oci_connect('user', 'pass', $db);
if (!$connection) {
$e = oci_error();
echo htmlentities($e['message']);
} */
?>
<?php
/*
function oracle_connect()
{
$user='user';
$pwd='pass';
$server='192.168.1.102'; // or ip
$port='1521';
$sid='****'; // service name
$charset='WE8ISO8859P1'; // change to whatever is needed

$conn=oci_connect($user,$pwd,'//'.$server.':'.$port.'/'.$sid,$charset);
if (!conn)
{
$e=oci_error();
trigger_error(htmlentities($e['message'], ENT_QUOTES), E_USER_ERROR);
echo $e;
echo "dfsdf<br />";
return FALSE;
}
else
echo "success";
return $conn;
}
$s = oci_parse($conn, "select * from 303"); */
?>

 

I get only a blank page! I`m not an IT guy but I can work well with PHP and MySQL...but Oracle gives me headaches...

Any ideas? Anyone?! :)

Link to comment
https://forums.phpfreaks.com/topic/274723-php-oracle-connection/
Share on other sites

  • 3 weeks later...

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.