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 metadata提取的PDF元数据,如何转换为一个Excel
  • ¥15 关于arduino编程toCharArray()函数的使用
  • ¥100 vc++混合CEF采用CLR方式编译报错
  • ¥15 coze 的插件输入飞书多维表格 app_token 后一直显示错误,如何解决?
  • ¥15 vite+vue3+plyr播放本地public文件夹下视频无法加载
  • ¥15 c#逐行读取txt文本,但是每一行里面数据之间空格数量不同
  • ¥50 如何openEuler 22.03上安装配置drbd
  • ¥20 ING91680C BLE5.3 芯片怎么实现串口收发数据
  • ¥15 无线连接树莓派,无法执行update,如何解决?(相关搜索:软件下载)
  • ¥15 Windows11, backspace, enter, space键失灵