调用未定义的函数oci_connect,php_oci8_12c.dll,Windows 8.1,php5.6.6 [英] Call to undefined function oci_connect, php_oci8_12c.dll, windows 8.1, php5.6.6

查看:113
本文介绍了调用未定义的函数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

我已经安装了即时客户端(12.1)-尝试过32位版本和64位版本

I have installed instant client (12.1) - tried 32 bit version AND 64 bit version

我有ORACLE_HOME和TNS_ADMIN环境变量指向即时客户端文件夹(C:\ instantclient_12_1).

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://网站下载了SQLDeveloper www.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 

一些其他有用的信息:

理想情况下,我想使用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.6\php.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-sdk\oracle\x86\instantclient_12_1\sdk,shared" "--with-oci8-12c=c:\php-sdk\oracle\x86\instantclient_12_1\sdk,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:\php\php.ini-production复制到c:\php\php.ini.
  • 中的
  • :
    • 启用了行extension_dir = "ext".
    • 启用了行extension=php_oci8_12c.dll.
    • Download and extract PHP (I used C:\php from php-5.6.7-nts-Win32-VC11-x86.zip).
    • Download and extract InstantClient (I used C:\instantclient_12_1 from instantclient-basic-nt-12.1.0.2.0.zip).
    • Add the above paths to the system path.
    • Copy c:\php\php.ini-production to c:\php\php.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的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆