Call to undefined function oci_connect, php_oci8_12c.dll, windows 8.1, php5.6.6(调用未定义的函数 oci_connect、php_oci8_12c.dll、windows 8.1、php5.6.6)
问题描述
我有一个简单的 php 脚本:
I have a simple php script:
<?php
$db_user = 'myusername';
$db_pass = 'mypassword';
$db_sid = 'mysid';
$conn = oci_connect( $db_user, $db_pass, $db_sid );
?>
当我运行它时(从浏览器或命令行),我收到错误:
When I run it (from a browser or from the command line), I get the error:
Call to undefined function oci_connect
我正在使用 php_oci8_12c.dll 附带的 php 5.6.6.
I'm using php 5.6.6 which came with php_oci8_12c.dll already there.
我的 php.ini 中有 extension=php_oci8_12c.dll
I have extension=php_oci8_12c.dll
in my php.ini
我已经安装了 Instant Client (12.1) - 尝试了 32 位版本和 64 位版本
I have installed instant client (12.1) - tried 32 bit version AND 64 bit version
我有指向即时客户端文件夹 ( C:instantclient_12_1 ) 的 ORACLE_HOME 和 TNS_ADMIN 环境变量.
I have ORACLE_HOME and TNS_ADMIN environment variables pointing at the instant client folder ( C:instantclient_12_1 ).
我的路径中也有 C:instantclient_12_1
I also have C:instantclient_12_1 in my path
我在同一个文件夹中有一个 tnsnames.ora,其中包含此相关条目:
I have a tnsnames.ora in that same folder with this relevant entry in it:
MYSID =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = myhost.net)(PORT = 1521))
(CONNECT_DATA =
(SERVER = DEDICATED)
(SERVICE_NAME = MYSERVICE)
)
)
我还从 http://下载了 SQLDeveloperwww.oracle.com/technetwork/developer-tools/sql-developer/downloads/index.html
SQLDeveloper 工作,识别上面提到的 tnsnames.ora 并连接并成功地在我的 php 脚本试图访问的同一个数据库上运行查询.
SQLDeveloper works, recognizes the above mentioned tnsnames.ora and connects and successfully runs a query on the same database that my php script is trying to access.
几天来,我花了几个小时尝试不同的事情,但都无济于事.
I have spent several hours over several days trying different things to no avail.
我正在使用:
php 5.6.6
windows 8.1
IIS (so no answers involving apache please)
cmd (run as administrator)
Oracle Database 11g Enterprise Edition 11.2.0.3.0
其他一些可能有用的信息:
Some other information that might prove useful:
理想情况下,我希望使用 oci 1.4.10 来匹配生产服务器,但现在不太担心.
I would ideally like to use oci 1.4.10 to match the production server, but not too worried about that for now.
pear install oci8-1.4.10.tgz
给我这个错误:
The DSP oci8.dsp does not exist
我找不到任何对我有意义的错误的解释.
I can't find any explanation on that error that means anything to me.
我错过了什么 - 谁能帮帮我
What am I missing - can anyone help me
我已经尝试了其他关于 stackoverflow 的帖子中的各种建议,即:
I have tried the various suggestions in other posts on stackoverflow, namely:
extension=oci8.so
有和没有 extension=php_oci8_12c.dll
我的 php.ini 文件中没有 extension=php_oracle.dll
行
I don't have the line extension=php_oracle.dll
in my php.ini file
phpinfo 告诉我我使用的是正确的 php.ini 文件:
phpinfo tells me that I am using the correct php.ini file:
Loaded Configuration File => C:php5.6.6php.ini
phpinfo 中的这一行也可能有用:
This line from phpinfo might also be of use:
Configure Command => cscript /nologo configure.js "--enable-snapshot-build" "--enable-debug-pack" "--disable-zts" "--disable-isapi" "--disable-nsapi" "--without-mssql" "--without-pdo-mssql" "--without-pi3web" "--with-pdo-oci=c:php-sdkoraclex86instantclient_12_1sdk,shared" "--with-oci8-12c=c:php-sdkoraclex86instantclient_12_1sdk,shared" "--with-enchant=shared" "--enable-object-out-dir=../obj/" "--enable-com-dotnet=shared" "--with-mcrypt=static" "--without-analyzer" "--with-pgo"
似乎 dsp 文件是 VC++ 项目文件 - 我现在正在冒险学习如何创建 php 扩展,希望当我完成后我将有足够的知识将 oci8 1.4.10 源代码编译成一个适用于 Windows 8 的 dll - 除非有人用这个问题的答案来拯救我 - 这看起来需要我一些时间:-)
It seems that dsp files are VC++ project files - I am now venturing on learning how to create a php extension, and hopefully when I've done that I'll have enough knowledge to compile the oci8 1.4.10 source code into a dll that works on windows 8 - unless somebody rescues me with the answer to this question - this looks like it is going to take me some time :-)
向 php.ini 添加 display_startup_errors = On
告诉我 oci dll 不是有效的 Win32 应用程序
Adding display_startup_errors = On
to php.ini tells me that the oci dll is not a valid Win32 application
推荐答案
嗯.在 Windows 8 上尝试此操作似乎会生成与您指定的相同的错误.我目前正在调查...
我的错误(我启用了错误的 extension_dir
行).它在 Win8 中的工作原理如下所述.
My mistake (I had enabled the wrong extension_dir
line). It works in Win8 just as documented below.
以下步骤应该是让 OCI 使用 PHP 所需的全部步骤(我刚刚在新安装的 Windows 2008 R2 Standard x64 虚拟机上验证了这一点):
The following steps should be all you need to get OCI working with PHP (I've just verified this on a freshly installed Windows 2008 R2 Standard x64 virtual machine):
- 下载并提取 PHP(我使用了
php-5.6.7-nts-Win32-VC11-x86.zip
中的C:php
). - 下载并提取 InstantClient(我使用了
instantclient-basic-nt-12.1.0.2.0.zip
中的C:instantclient_12_1
). - 将上述路径添加到系统路径中.
- 将
c:phpphp.ini-production
复制到c:phpphp.ini
. - 在
php.ini
中:- 启用行
extension_dir = "ext"
. - 启用行
extension=php_oci8_12c.dll
.
- Download and extract PHP (I used
C:php
fromphp-5.6.7-nts-Win32-VC11-x86.zip
). - Download and extract InstantClient (I used
C:instantclient_12_1
frominstantclient-basic-nt-12.1.0.2.0.zip
). - Add the above paths to the system path.
- Copy
c:phpphp.ini-production
toc:phpphp.ini
. - in
php.ini
:- enabled line
extension_dir = "ext"
. - enabled line
extension=php_oci8_12c.dll
.
此时在命令提示符中运行
php --ri oci8
会显示以下输出:At this point running
php --ri oci8
in a command prompt shows me the following output:C:>php --ri oci8 oci8 OCI8 Support => enabled OCI8 DTrace Support => disabled OCI8 Version => 2.0.9 Revision => $Id: f5a3ee1083d1ffa6adb5143efda6eafa210b8414 $ Oracle Run-time Client Library Version => 12.1.0.2.0 Oracle Compile-time Instant Client Version => 12.1 Directive => Local Value => Master Value oci8.max_persistent => -1 => -1 oci8.persistent_timeout => -1 => -1 oci8.ping_interval => 60 => 60 oci8.privileged_connect => Off => Off oci8.statement_cache_size => 20 => 20 oci8.default_prefetch => 100 => 100 oci8.old_oci_close_semantics => Off => Off oci8.connection_class => no value => no value oci8.events => Off => Off Statistics => Active Persistent Connections => 0 Active Connections => 0
并检查
oci_connect
函数:C:>php -r "var_dump(function_exists('oci_connect'));" bool(true)
这篇关于调用未定义的函数 oci_connect、php_oci8_12c.dll、windows 8.1、php5.6.6的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
- enabled line
- 启用行
本文标题为:调用未定义的函数 oci_connect、php_oci8_12c.dll、windows 8.1、php5.6.6
基础教程推荐
- 如何在 Symfony 和 Doctrine 中实现多对多和一对多? 2022-01-01
- Doctrine 2 - 在多对多关系中记录更改 2022-01-01
- 使用 PDO 转义列名 2021-01-01
- 如何在 XAMPP 上启用 mysqli? 2021-01-01
- 在 yii2 中迁移时出现异常“找不到驱动程序" 2022-01-01
- phpmyadmin 错误“#1062 - 密钥 1 的重复条目‘1’" 2022-01-01
- HTTP 与 FTP 上传 2021-01-01
- 在 CakePHP 2.0 中使用 Html Helper 时未定义的变量 2021-01-01
- PHP 守护进程/worker 环境 2022-01-01
- 找不到类“AppHttpControllersDB",我也无法使用新模型 2022-01-01