dounie0889 2016-11-28 11:33
浏览 230
已采纳

调用未定义的函数oci_connect,php_oci8_11g.dll,windows 10,php5.6.24

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.
";
                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

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  

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.

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.

When I have tried the following command :

php --ri oci8

I have the following error :

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.

How can I remove the following error ?

Fatal error: Call to undefined function oci_connect() 
  • 写回答

2条回答 默认 最新

  • dongmijgnnq0118 2016-11-28 12:02
    关注

    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:

    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
    

    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

    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.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥15 Python爬取指定微博话题下的内容,保存为txt
  • ¥15 vue2登录调用后端接口如何实现
  • ¥65 永磁型步进电机PID算法
  • ¥15 sqlite 附加(attach database)加密数据库时,返回26是什么原因呢?
  • ¥88 找成都本地经验丰富懂小程序开发的技术大咖
  • ¥15 如何处理复杂数据表格的除法运算
  • ¥15 如何用stc8h1k08的片子做485数据透传的功能?(关键词-串口)
  • ¥15 有兄弟姐妹会用word插图功能制作类似citespace的图片吗?
  • ¥15 latex怎么处理论文引理引用参考文献
  • ¥15 请教:如何用postman调用本地虚拟机区块链接上的合约?