[英]Call to undefined function oci_connect, php_oci8_11g.dll , windows 10, php5.6.24
I have a simple php script: 我有一个简单的php脚本:
<?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
I'm using php 5.6.24 . 我正在使用php 5.6.24。 I have copied php_oci8.dll and php_oci8_11g.dll to /ext folder .
我已经将php_oci8.dll和php_oci8_11g.dll复制到/ ext文件夹中。 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 . 在我的php.ini中,我已经安装了即时client_11_2-尝试了32位版本。 I have ORACLE_HOME and TNS_ADMIN environment variables pointing at the instant client folder ( C:\\instantclient_11_2 ).
我有ORACLE_HOME和TNS_ADMIN环境变量指向即时客户端文件夹(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). 我已经安装了Microsoft Visual C ++ 2010运行时(x86)。 This is needed for the OCI8 extension.
OCI8扩展需要此功能。 I have Installed Microsoft Visual C++ 2012 Runtime (x86).
我已经安装了Microsoft Visual C ++ 2012 Runtime(x86)。 This is needed for PHP.
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()
You are getting startup errors for the OCI8 extension indicating that you are using an unsupported dll for your php version. 您收到OCI8扩展程序的启动错误,表明您使用的PHP版本不支持dll。 You need to use the correct one, which - for PHP 5.6.x - is one of these:
您需要使用正确的一种,对于PHP 5.6.x,这是其中一种:
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, eg if you are running a thread-safe PHP 5.6.24 compiled with vc11 on an x86, you'd use 您需要采用与您的体系结构(x86或x64),编译器(vc 9、11、14)和线程安全(ts)或非线程安全(nts)php版本相匹配的版本,例如,如果您正在运行在x86上用vc11编译的线程安全PHP 5.6.24,您将使用
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. 如果没有与您的PHP匹配的下载文件,则说明该文件不存在,因此您需要自己进行编译。 More info at http://windows.php.net
有关更多信息, 请访问http://windows.php.net
On a side note: in addition to the above, you can only use one oci extension at a time. 附带说明:除上述内容外,您一次只能使用一个oci扩展名。 You got both (php_oci8.dll and php_oci8_11g.dll).
您同时拥有了(php_oci8.dll和php_oci8_11g.dll)。 Make sure to remove the one you don't need.
确保删除不需要的那个。
You can only enable one of these at a time: extension=php_oci8.dll extension=php_oci8_11g.dll
They both enable the same OCI8 extension but they require different Oracle Instant Client versions. 您一次只能启用其中之一:
extension=php_oci8.dll extension=php_oci8_11g.dll
它们都启用相同的OCI8扩展,但是它们需要不同的Oracle Instant Client版本。 You say you are using Instant Client 11.2, so comment out the first extension. 您说您正在使用Instant Client 11.2,因此请注释掉第一个扩展。
Make sure you add the Instant Client directory to PATH
. 确保将Instant Client目录添加到
PATH
。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.