duanlu0559
2012-02-09 17:45
浏览 29

PHP无法连接,但SqlPlus可以

Here is an issue that is boggling my cells right now.

There is an oracle server that I want to connect to. I can easily connect to it using the sqlplus command line.

When I try to connect to the oracle database with PHP though, it fails. Here is the catch, we have the same setup in another datacenter; a PHP machine is trying to connect to an oracle database. I've run the exact same code, configured php identically on both PHP machines.

PHP1 can connect to Oracle1 with both sqlplus and through php.

PHP2 connects to Oracle2 with sqlplus but NOT with PHP.

There are firewalls and some port blocking going on. My current explanation is that the port php2 is using to connect to oracle2 is not the default 1521 and it is being blocked.

The ora error I get is :

ORA-06413 : Connection not open.

Any ideas?

图片转代码服务由CSDN问答提供 功能建议

这是一个让我的细胞立刻感到困惑的问题。

那里 是我想要连接的oracle服务器。 我可以使用sqlplus命令行轻松连接到它。

当我尝试使用PHP连接到oracle数据库时,它失败了。 这是捕获,我们在另一个数据中心有相同的设置; PHP机器正在尝试连接到oracle数据库。 我运行完全相同的代码,在两台PHP机器上配置相同的php。

PHP1可以通过sqlplus和php连接到Oracle1。

PHP2使用sqlplus连接到Oracle2但不使用PHP连接到Oracle2。

有防火墙和一些端口阻塞正在进行。 我目前的解释是,用于连接oracle2的端口php2不是默认的1521并且它被阻止。

我得到的ora错误是: \ n

ORA-06413:连接未打开。

有任何想法吗?

  • 写回答
  • 关注问题
  • 收藏
  • 邀请回答

2条回答 默认 最新

  • dongyu9894 2012-02-10 08:47
    已采纳

    The error indicates that the TNS connect descriptor can't be parsed for one reason or another. It's usually a problem with a system call made by Oracle when it's attempting to build connection information.

    Are there any brackets in your program name, username, or machine name?

    Are you running a 32-bit Oracle client on a 64-bit Windows OS by any chance?

    Try using the tnsping utility from the command line. What does that tell you?

    打赏 评论
  • dst8922 2012-02-09 18:10

    From the info provided, my best guess (narrowing it to programming causes) is that either the database name, username or password sent from the problem machine contains an escape sequence ($, \t, \a, , etc.) that, when typed in your PHP script as a string literal, becomes altered.

    打赏 评论

相关推荐 更多相似问题