PHP can't connect, but SqlPlus can

给你一囗甜甜゛ 提交于 2019-12-11 03:48:54

问题


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?


回答1:


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?




回答2:


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, \r, etc.) that, when typed in your PHP script as a string literal, becomes altered.



来源:https://stackoverflow.com/questions/9215983/php-cant-connect-but-sqlplus-can

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!