我使用 apt-get install 安装了 unixODBC,现在当我尝试使用 odbc_connect() 时仍然出现此错误。
PHP Fatal error: Call to undefined function odbc_connect()
我需要做些什么来配置它以使用 php?我一直在网上寻找,但我无法弄清楚。
我认为您还需要安装 php5-odbc。unixODBC 提供驱动程序管理器,但您需要调用它的 PHP 代码。
在 CentOS 6.3 和 PHP 5.3.16 上也有同样的问题。但解决方法是使用 yum 安装 php-odbc。
yum install php-odbc
Did you add it to your LD_LIBRARY_PATH
? Check the documentation for your server, it may require third-party libraries to be in a specific sub-directory, or have some other mechanism for finding them. If so, you should be able to create a symbolic link to the library. That way, if it gets updated, your server will automatically use it.
我们也有这个问题。我们安装了 php5-odbc,但仍然有问题。事实证明,我们需要重新启动 Linux 才能让 php 看到该功能。回收 Apache 还不够!
确保通过odbc
为您的 Apache 启用扩展a2enmod odbc
。
然后通过以下方式检查是否存在:apache2ctl -M
。
如果您没有此扩展程序,请通过安装apt-get install php-odbc
(yum
在 CentOS 的情况下使用)。
另请参阅:在 Linux 和 macOS 上安装 Microsoft ODBC Driver for SQL Server。