调用未定义的函数oci_connect,php_oci8_11g.dll,Windows 10,php5.6.24 [英] Call to undefined function oci_connect, php_oci8_11g.dll , windows 10, php5.6.24

查看:86
本文介绍了调用未定义的函数oci_connect,php_oci8_11g.dll,Windows 10,php5.6.24的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个简单的php脚本:

I have a simple php script:

<?php


            $DB = '//10.11.201.170:1521/XE';
            $DB_USER = 'BIOTPL';
            $DB_PASS = 'biotpl';
            $DB_CHAR = 'AL32UTF8';

            $conn = oci_connect($DB_USER, $DB_PASS, $DB, $DB_CHAR);
            if($conn)
            {
                echo "Successfully connected to Oracle.\n";
                OCILogoff($c);
                //$statement = oci_parse($conn, 'select 1 from dual');
                //oci_execute($statement);
                //$row = oci_fetch_array($statement, OCI_ASSOC+OCI_RETURN_NULLS);
            }
            else
            {
                $err = OCIError();
                echo "Connection failed." . $err[text];
            }  
?>

当我从浏览器或命令行运行它时,出现错误:

When I run it (from a browser or from the command line), I get the error::

Call to undefined function oci_connect

我正在使用php 5.6.24.我已经将php_oci8.dll和php_oci8_11g.dll复制到/ext文件夹中.我有

I'm using php 5.6.24 . I have copied php_oci8.dll and php_oci8_11g.dll to /ext folder . I have

extension=php_oci8.dll 
extension=php_oci8_11g.dll  

在我的php.ini中 我已经安装了即时client_11_2-尝试使用32位版本.我有ORACLE_HOME和TNS_ADMIN环境变量指向即时客户端文件夹(C:\ instantclient_11_2).

in my php.ini I have installed instant client_11_2 - tried 32 bit version . I have ORACLE_HOME and TNS_ADMIN environment variables pointing at the instant client folder ( C:\instantclient_11_2 ).

几天来,我花了几个小时尝试各种不同的尝试.

I have spent several hours over several days trying different things to no avail.

我已经安装了Microsoft Visual C ++ 2010运行时(x86).这是OCI8扩展所必需的.我已经安装了Microsoft Visual C ++ 2012 Runtime(x86).这是PHP所需的.

I have Installed Microsoft Visual C++ 2010 Runtime (x86). This is needed for the OCI8 extension. I have Installed Microsoft Visual C++ 2012 Runtime (x86). This is needed for PHP.

当我尝试以下命令时:

php --ri oci8

我遇到以下错误:

PHP Warning:  PHP Startup: Unable to load dynamic library 'C:\xampp\php\ext\php_oci8.dll' - %1 is not a valid Win32 application.
 in Unknown on line 0

Warning: PHP Startup: Unable to load dynamic library 'C:\xampp\php\ext\php_oci8.dll' - %1 is not a valid Win32 application.
 in Unknown on line 0
PHP Warning:  PHP Startup: Unable to load dynamic library 'C:\xampp\php\ext\php_oci8_11g.dll' - %1 is not a valid Win32 application.
 in Unknown on line 0

Warning: PHP Startup: Unable to load dynamic library 'C:\xampp\php\ext\php_oci8_11g.dll' - %1 is not a valid Win32 application.
 in Unknown on line 0
Extension 'oci8' not present.

如何清除以下错误?

Fatal error: Call to undefined function oci_connect() 

推荐答案

您收到OCI8扩展程序的启动错误,表明您使用的PHP版本不支持dll.您需要使用正确的选项之一-对于PHP 5.6.x-是其中一种:

You are getting startup errors for the OCI8 extension indicating that you are using an unsupported dll for your php version. You need to use the correct one, which - for PHP 5.6.x - is one of these:

您需要使用与您的体系结构(x86或x64),编译器(vc 9、11、14)和线程安全(ts)或非线程安全(nts)php版本相匹配的版本,例如如果您在x86上运行使用vc11编译的线程安全的PHP 5.6.24,则应使用

You need to take the one that matches your architecture (x86 or x64), compiler (vc 9, 11, 14) and thread-safe (ts) or non-thread-safe (nts) php version, e.g. if you are running a thread-safe PHP 5.6.24 compiled with vc11 on an x86, you'd use

php_oci8-2.0.8-5.6-ts-vc11-x86.zip
-------- ----- --- -- ---- --- ---
^        ^     ^   ^  ^    ^   ^
|        |     |   |  |    |   \_____ extension
|        |     |   |  |    \_________ architecture
|        |     |   |  \______________ compiler
|        |     |   \_________________ thread-safety mode
|        |     \_____________________ php version
|        \___________________________ extension version
\____________________________________ extension name

如果没有与您的PHP匹配的下载文件,则说明该文件不存在,因此您需要自己进行编译.有关更多信息,请参见 http://windows.php.net

If there is no download matching your PHP, then it does not exist and you need to compile it yourself. More info at http://windows.php.net

附带说明:除上述内容外,您一次只能使用一个oci扩展名.您同时拥有了(php_oci8.dll和php_oci8_11g.dll).确保删除不需要的.

On a side note: in addition to the above, you can only use one oci extension at a time. You got both (php_oci8.dll and php_oci8_11g.dll). Make sure to remove the one you don't need.

这篇关于调用未定义的函数oci_connect,php_oci8_11g.dll,Windows 10,php5.6.24的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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