调用未定义的函数 odbc_connect() php 7

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/34321203/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-25 23:54:59  来源:igfitidea点击:

Call to undefined function odbc_connect() php 7

php

提问by bones

I'm testing out php 7 and have come across this error:

我正在测试 php 7 并遇到了这个错误:

Fatal error: Uncaught Error: Call to undefined function odbc_connect()

致命错误:未捕获错误:调用未定义的函数 odbc_connect()

From the doc page: http://php.net/manual/en/function.odbc-connect.phpphp 7 is not listed as supported.

从文档页面:http: //php.net/manual/en/function.odbc-connect.phpphp 7 未列为受支持。

Does anyone have a way around this or know when it will be supported?

有没有人有办法解决这个问题或知道什么时候会得到支持?

Thanks@

谢谢@

采纳答案by Naidim

The DOC page does list PHP 7, so just install php-odbc and you should be good to go. Currently using it myself on RedHat EL7 with Remi php7.

DOC 页面确实列出了 PHP 7,所以只需安装 php-odbc 就可以了。目前我自己在 RedHat EL7 上使用 Remi php7。

回答by Hink

There is written in doc: ODBC support doesn't need any extension dll. It is true in PHP 5.x, I had to remove "extension=php_odbc.dll" from ini file.
But in PHP 7 I had to put it back.

文档中写道:ODBC 支持不需要任何扩展 dll。在 PHP 5.x 中确实如此,我不得不从 ini 文件中删除“extension=php_odbc.dll”。
但是在 PHP 7 中我不得不把它放回去。

I found the file "ext/php_odbc.dll" in the new PHP 7 directory again. It works for me :).

我再次在新的 PHP 7 目录中找到了文件“ext/php_odbc.dll”。这个对我有用 :)。

回答by Kanna Reddy

PHP 7.2.7, add extension=php_odbc.dllin php.inifile while either using database as MS Access or Sql Server C:\xxxxxx\php\php.ini

PHP 7.2.7,在php.ini文件中添加extension=php_odbc.dll,同时使用数据库作为 MS Access 或 Sql Server C:\xxxxxx\php\php.ini

*no semicolon before to extension=php_odbc.dll

*扩展名前没有分号=php_odbc.dll

回答by irwinr

I ran into the same problem. However according to the link you provided PHP7 is in fact supported. So I'm not sure why you have so many comments telling you to go re-write your code.

我遇到了同样的问题。但是,根据您提供的链接,实际上支持 PHP7。所以我不知道为什么你有这么多评论告诉你去重写你的代码。

This is what ultimately fixed the issue for me:

这就是最终为我解决问题的原因:

sudo apt-get install php-odbc

Followed by restarting Apache.

接着是重启Apache。

回答by Lenin Oca?a

Just enble "php_odbc.dll" extension by removing the semicolon and restart Apache.

只需通过删除分号并重新启动Apache来启用“php_odbc.dll”扩展。

If there is no such line in php.ini, simply create it on yourself (you will find many similar lines in php.ini) by adding: extension=php_odbc.dlland then restart Apache.

如果 php.ini 中没有这样的行,只需自己创建(在 php.ini 中你会发现很多类似的行),添加:extension=php_odbc.dll然后重新启动 Apache。

If Apache does not start or cannot load php_odbc.dll, look into to the ext-Folder of PHP, if there is such a DLL called php_odbc.dll. If there is no such DLL, Xampp/PHP7 does not support ODBC natively. In that case you should install an older Xampp Version with PHP 5.x

如果Apache不启动或无法加载php_odbc.dll,请查看PHP的ext-Folder,是否有名为php_odbc.dll的DLL。如果没有这样的 DLL,则 Xampp/PHP7 本身不支持 ODBC。在这种情况下,您应该使用 PHP 5.x 安装较旧的 Xampp 版本

回答by user2928048

From php.ini file:

从 php.ini 文件:

> ; Notes for Windows environments :
> ;
> ; - ODBC support is built in, so no dll is needed for it.
> ; - Many DLL files are located in the extensions/ (PHP 4) or ext/ (PHP 5+)

But, in PHP 7, ODBC is not by default. Explicit

但是,在 PHP 7 中,ODBC 不是默认的。显式

extension=odbc

worked for me (new syntax recommended)

为我工作(推荐新语法)

Edit: If your architecture is x64 you must use C:\Windows\SysWOW64\odbcad32.exe instead of C:\Windows\system32\odbcad32.exe

编辑:如果您的架构是 x64,则必须使用 C:\Windows\SysWOW64\odbcad32.exe 而不是 C:\Windows\system32\odbcad32.exe