我有MSSQL 2008,MS WINDOWS Server 2008 RC2和PHP5.4
php.info有行
[PHP_PDO_SQLSRV_54_NTS]
extension=php_pdo_sqlsrv_54_nts.dll
[PHP_PDO_ODBC]
extension=php_pdo_odbc.dll
[PHP_SYBASE_CT]
extension=php_sybase_ct.dll
[PHP_SQLSRV_54_NTS]
extension=php_sqlsrv_54_nts.dllPhp在这里找到http://89.111.180.28/index.php
我看到了带有扩展php.ini的行,但是在php.info.中没有看到带有扩展SQLSRV的行
为了连接到MSSQL服务器,我使用脚本
$conn_array = array (
"UID" => "user",
"PWD" => "passw",
"Database" => "database",
"Encrypt" => 1,
"TrustServerCertificate" => 1) ;
$conn2 = sqlsrv_connect('localhost' , $conn_array);
if ($conn2)
{
echo 'MSSQL Connection successful';
}
else
{
die( print_r( sqlsrv_errors(), true));
}
sqlsrv_close( $conn2 );但我看到了错误:
Fatal error: Call to undefined function sqlsrv_connect() in C:\inetpub\wwwroot\89.111.180.28\index.php on line 18请告诉我,为什么我有错误,如何做正确的?
服务器已经重新启动。
发布于 2016-01-26 03:06:27
我自己也有这个问题。我终于把它修好了,所以我想我可以分享一下。
问题是,虽然我安装了sqlsrv (复制到我的php/ext文件夹),并且在我的php.ini中添加了它,在IIS中添加了,但是它是“禁用”。
这里有一些逐步的说明,以防有人再次出现同样的问题。(或供我日后参考:)
- Install them by running the .exe, and typing the path to your php extensions folder when it asks you where to decompress them.
- To find your current extension directory, run (cmd.exe) `php -i | more`, and look for the line `extension_dir`. (For me it was on the fourth press of `more`). Alternately, make a simple php file containing only `<?php phpinfo(); ?>`, and run it in the browser. This will give the same information, but in a much easier-to-read format.
- To find the right php.ini, either run `php -i | more` again, looking for `Loaded Configuration File`, or check that simple php script again (I highly recommend you make it - it'll save you time and effort). The path you find there is the file you need to edit.
- Add the following lines to your php.ini, and save it: [PHP_SQLSRV] extention=php_sqlsrv_56_nts.dll
- In the start menu, type `IIS Manager`, and press enter.
- Click on your Server's name in the left side bar
- Click `PHP Manager`
- Under `PHP Extensions`, click `Enable or Disable an Extension`.
- If your extension is not under `Enabled`, look under `Disabled` for it. When you find it, right-click on it, and click `Enable` in the context menu that appears.
- Open that `phpinfo()` page you made (you did, didn't you?), and look under `Registered PHP Streams`. If you see `sqlsrv` in that list, you're set!
发布于 2012-12-05 08:48:51
我明白现在的情况。
我使用的PHP版本在5.4以上,所以使用PHP驱动程序进行Windows3.0。
对于此配置,需要SQL 2012的客户端版本,但我一直是客户端SQL 2008版本。
问题解决了。
发布于 2020-02-28 20:15:35
如果使用sql server 2008 r2,则只需下载丢失的组件,如数据库管理器和microsoft sql server 2008R2管理对象,并继续下载直到成功为止。
https://stackoverflow.com/questions/13703824
复制相似问题