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.

    评论

报告相同问题?

悬赏问题

  • ¥20 用vivado写数字逻辑实验报告撰写,FPGA实验
  • ¥15 为什么shp文件会有这种小方块?
  • ¥15 ecplise在连接数据库时显示加载驱动成功但是数据库连接失败
  • ¥15 visionmaster启动失败,提示为“机器不满足授权而被禁用”
  • ¥15 IDEA中圈复杂度如何具体设置
  • ¥50 labview采集不了数据
  • ¥15 Multisim红外倒车雷达仿真中距离问题
  • ¥15 请上面代码做什么处理或什么混淆
  • ¥15 英雄联盟自定义房间置顶
  • ¥15 W5500网线插上无反应