douxiuyu2028 2015-05-25 09:38
浏览 90

php(xampp)的oracle连接问题

I need to connect oracle 11g database with my xampp server and I need both local and remote connection. For that what I did is first I installed the oracle 11g express edition and the downloaded the instantclient-basic-nt-11.2.0.4.0 and placed the extracted folder instantclient_11_2 in C:\ then I set the environment variable (system variables) and my path value looks like this path=C:\oraclexe\app\oracle\product\11.2.0\server\bin;C:\instantclient_11_2.

Then I removed the ; before extension=php_oci8.dll and extension=php_oci8_11g.dll from the php.ini file. Then first I tried to connect with my local database:

$tns_turjo = '(DESCRIPTION = (ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.0.13)(PORT = 1521)) (CONNECT_DATA = (SERVER = DEDICATED) (SERVICE_NAME = XE)))'; // tns of another pc
$tns_ishrak = '(DESCRIPTION = (ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.0.18)(PORT = 1521)) (CONNECT_DATA = (SERVER = DEDICATED) (SERVICE_NAME = XE)))'; // tns of my pc

$conn = oci_connect('system', 'cibl123*#', $tns_turjo);
if($conn) {
    echo "connected";
}
else {
    echo "not";
}

When I pass $tns_ishrak it echoes connected but when I try to access the oracle database of another pc i.e. use the $tns_turjo then it echoes not and the error is

Message: oci_connect(): ORA-12170: TNS:Connect timeout occurred

I have also changed the username and password while connecting to another pc.

N.B. After enabling the .dll extensions from the php.ini file whenever I start the Apache I get a pop up warning in xampp which is Module 'oci8' is already loaded

How can I solve the remote connection issue?

  • 写回答

1条回答 默认 最新

  • dongzizhi9903 2015-05-25 11:48
    关注

    You don't need the InstantClient installed; Oracle XE includes a full Oracle client.

    There are many possible reasons why a remote connection does not work, but the most common (in my experience) are:

    1. The firewall on your PC is blocking the connection.
    2. The firewall on the remote PC is blocking the connection.
    3. The TNS listener is not running on the remote PC.
    4. The connection string is wrong.

    Can you connect to the remote PC without PHP? Have you tried via SQL*Plus or simply a tnsping command?


    N.B. After enabling the .dll extensions from the php.ini file whenever I start the Apache I get a pop up warning in xampp which is Module 'oci8' is already loaded

    That's quite self-explanatory: you are trying to load the OCI module more than once. You should only have one OCI module enabled so if you've something like the below in your php.ini file then that's the problem:

    extension=php_oci8.dll
    extension=php_oci8_11g.dll
    

    Only php_oci8_11g.dll should be enabled since that's the version you have installed.

    评论

报告相同问题?

悬赏问题

  • ¥15 delta降尺度计算的一些细节,有偿
  • ¥15 Arduino红外遥控代码有问题
  • ¥15 数值计算离散正交多项式
  • ¥30 数值计算均差系数编程
  • ¥15 redis-full-check比较 两个集群的数据出错
  • ¥15 Matlab编程问题
  • ¥15 训练的多模态特征融合模型准确度很低怎么办
  • ¥15 kylin启动报错log4j类冲突
  • ¥15 超声波模块测距控制点灯,灯的闪烁很不稳定,经过调试发现测的距离偏大
  • ¥15 import arcpy出现importing _arcgisscripting 找不到相关程序