尝试加载 php_oci8.dll 时在启动时出现 PHP 警告

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/20825405/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-25 03:35:15  来源:igfitidea点击:

PHP Warning at startup while trying to load php_oci8.dll

phporacleoci

提问by Kelu Thatsall

I'm using XAMPP and trying to configure Oracle connection for sql.

我正在使用 XAMPP 并尝试为 sql 配置 Oracle 连接。

I uncommented the line extension=php_oci8.dlland at first it ended up with an error (that oci.dll is missing), but later I downloaded instantclient from Oracle web pages. I tried with versions 10.2, 11.2, and 12.1 but neither worked. Obviously I've added the path to those libraries to my PATHenv variable.

我取消了该行的注释extension=php_oci8.dll,起初它以错误结束(缺少 oci.dll),但后来我从 Oracle 网页下载了 Instantclient。我尝试过 10.2、11.2 和 12.1 版本,但都没有奏效。显然,我已将这些库的路径添加到我的PATHenv 变量中。

The warning I'm getting at the startup of Apache is: PHP Warning: PHP Startup: in Unknown on line 0

我在 Apache 启动时收到的警告是: PHP Warning: PHP Startup: in Unknown on line 0

The error when I'm trying to connect is: PHP Fatal error: Call to undefined function oci_connect() in ...

我尝试连接时的错误是: PHP Fatal error: Call to undefined function oci_connect() in ...

I've tried with php_oci8.dlland php_oci8_11g.dll. Those files are in my php/extdirectory (they were included in xampp), my instantclient is added to PATHand the warning doesn't show up if I disable those modules. I've tried restarting services and computer.

我试过php_oci8.dllphp_oci8_11g.dll。这些文件在我的php/ext目录中(它们包含在 xampp 中),我的 Instantclient 被添加到PATH,如果我禁用这些模块,则不会显示警告。我试过重新启动服务和计算机。

Can you help me find a solution how to configure it correctly? I'm using Windows 8.1 with administrative privileges.

你能帮我找到一个如何正确配置它的解决方案吗?我正在使用具有管理权限的 Windows 8.1。

BTW. My phpinfo()says that OCI8 is activated (but functions like oci_connectstill don't work).

顺便提一句。我phpinfo()说OCI8已激活(但功能oci_connect仍然不起作用)。

EDIT:When I tried running PHP manually I finally got the error to display what was wrong: Unable to load dynamic library 'C:\Program Files (x86)\PHP\ext\php_oci8_11g.dll' - %1 is not a valid Win32 application. in Unknown on line 0Can you help me find out where can I download a correct version?

编辑:当我尝试手动运行 PHP 时,我终于得到错误以显示错误:Unable to load dynamic library 'C:\Program Files (x86)\PHP\ext\php_oci8_11g.dll' - %1 is not a valid Win32 application. in Unknown on line 0您能帮我找出在哪里可以下载正确的版本吗?

采纳答案by Kelu Thatsall

There was a problem with 64bit version of instantclient. If you ever have the same issue, please install 32bit version of instantclient.

64 位版本的 Instantclient 存在问题。如果您遇到同样的问题,请安装 32 位版本的 Instantclient。

To be honest the easiest way is just to follow PROPER instructions: http://www.oracle.com/technetwork/articles/dsl/technote-php-instant-084410.html

老实说,最简单的方法就是遵循正确的说明:http: //www.oracle.com/technetwork/articles/dsl/technote-php-instant-084410.html

I tried a lot of other advices and they all went really bad on me (not just because I used different bit version - also I copied the files everywhere following stupid advices and it was hard to correct it)

我尝试了很多其他建议,但它们对我来说都非常糟糕(不仅仅是因为我使用了不同的位版本 - 而且我按照愚蠢的建议到处复制了文件并且很难纠正它)

回答by Umesh Patil

Its because your Oracle is 64 bit. Remove it and install a 32 bit version of Oracle client and it will work.

因为你的 Oracle 是 64 位的。删除它并安装 32 位版本的 Oracle 客户端,它将起作用。

回答by Ughini

There's an alternate way to solve this: Install the full Oracle Client, not the basic zip, you can get it at oracle site (about 1Gb):

有一种替代方法可以解决这个问题:安装完整的 Oracle 客户端,而不是基本的 zip,您可以在 oracle 站点上获取它(大约 1Gb):

http://www.oracle.com/technetwork/database/enterprise-edition/downloads/oracle12c-windows-3633015.html

http://www.oracle.com/technetwork/database/enterprise-edition/downloads/oracle12c-windows-3633015.html

Im using Windows 10, Apache 2.4, PHP 7.1 (all x64) and it works. Also tryed PHP 5.6 and it works too. Still use the php_oci8_11g.dll from the basic client zip to match your php and system version.

我使用的是 Windows 10、Apache 2.4、PHP 7.1(所有 x64)并且它可以工作。还尝试了 PHP 5.6,它也可以工作。仍然使用基本客户端 zip 中的 php_oci8_11g.dll 来匹配您的 php 和系统版本。

You can search the site to find older client versions (11g, 32bits, etc) but Im working with de 12c client and accessing an Oracle 11g enterprise server.

您可以搜索该站点以查找较旧的客户端版本(11g、32 位等),但我使用 de 12c 客户端并访问 Oracle 11g 企业服务器。

I found a lot of occurrencies of this same error all around, but none gave me this solution. Hope taht helps.

我发现很多地方都发生了同样的错误,但没有一个给我这个解决方案。希望有帮助。

回答by Xavier

It looks like your extension are not install properly. Try to update it or reinstall it with pecl with

看起来您的扩展程序没有正确安装。尝试使用 pecl 更新或重新安装它

pecl install extname

You should also check extension_dir directive in php.ini and check if the PHP folder is added to the path

您还应该检查 php.ini 中的 extension_dir 指令并检查 PHP 文件夹是否添加到路径中