使用WAMP调用未定义的函数sqlsrv_connect() [英] Call to undefined function sqlsrv_connect() with WAMP
问题描述
我知道这个问题已经在这个网站上被问过几次了,但我开始怀疑自己是否发疯了。
I know that this question has already been asked several times on this website but I'm seriously starting to wonder wheter I'm crazy or not.
我的配置:WampServer 2.5 64位(PHP 5.5.12,Apache 2.4.9)
My configuration : WampServer 2.5 64bits (PHP 5.5.12, Apache 2.4.9)
我的步骤:
- 从 https:/下载Microsoft驱动程序SQLSRV32.exe /www.microsoft.com/zh-cn/download/details.aspx?id=20098
- 从下载到我桌面上的.exe文件中提取文件
- 将 php_sqlsrv_55_ts.dll 和 php_pdo_sqlsrv_55_ts.dll 复制到 C:\wamp\bin\php\php5.5.12\ \ext
- 编辑 C:\wamp\bin\php\php5.5.12\php.ini 添加 extension = php_pdo_sqlsrv_55_ts.dll 和 extension = php_sqlsrv_55_ts.dll
- 编辑 C:\wamp\bin\ \apache\apache2.4.9\bin\php.ini ,添加 extension = php_pdo_sqlsrv_55_ts.dll 和 extension = php_sqlsrv_55_ts.dll
- 重新启动所有服务(我什至尝试重新启动计算机,但无济于事)
- Download Microsoft Driver SQLSRV32.exe from https://www.microsoft.com/en-us/download/details.aspx?id=20098
- Extract the files from the .exe downloaded on my desktop
- Copy php_sqlsrv_55_ts.dll and php_pdo_sqlsrv_55_ts.dll into C:\wamp\bin\php\php5.5.12\ext
- Edit C:\wamp\bin\php\php5.5.12\php.ini adding "extension=php_pdo_sqlsrv_55_ts.dll" and "extension=php_sqlsrv_55_ts.dll"
- Edit C:\wamp\bin\apache\apache2.4.9\bin\php.ini adding "extension=php_pdo_sqlsrv_55_ts.dll" and "extension=php_sqlsrv_55_ts.dll"
- Restart all services (I even tried to restart my computer, but nothing works)
我仍然会收到错误...那么,要使这项工作有效,我要缺少什么?
I still get the error... So what am I missing to make this work ?
推荐答案
仅安装PHP扩展是不够的,您还需要为SQLServer®-Windows安装Microsoft®ODBC Driver 11
Installing just the PHP extension is not enough, you also need to install Microsoft® ODBC Driver 11 for SQL Server® - Windows
确保您编辑正确的 php.ini
文件的最佳方法是使用wampmanager菜单。因此,将来可以:-
Also the best way to ensure you are editing the correct php.ini
file is to use the wampmanager menus. So in future do :-
wampmanager -> PHP -> php.ini
这会将正确的php.ini加载到yoru编辑器中。
This will load the correct php.ini into yoru editor.
C:\wamp\bin\php\php {version} \php.ini
仅由PHP CLI使用
C:\wamp\bin\php\php{version}\php.ini
is used only by PHP CLI
C:\wamp\bin\apache\apache {version} \bin\php.ini
仅在在Apache下运行时由PHP使用
C:\wamp\bin\apache\apache{version}\bin\php.ini
is used only by PHP when running under Apache
这篇关于使用WAMP调用未定义的函数sqlsrv_connect()的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!