简体   繁体   English

IIS上的PHP不加载sqlsrv扩展名

[英]PHP on IIS doesn't load sqlsrv extension

I'm trying to put together a page that can submit data from a form to an MSSQL database via PHP. 我正在尝试组建一个页面,可以通过PHP将表单中的数据提交到MSSQL数据库。 I've got PHP installed successfully ( phpinfo() runs fine even on a remote computer) but it will not load the sqlsrv extension . 我已成功安装PHP( phpinfo()即使在远程计算机上运行正常)但它不会加载sqlsrv扩展 I know that I'm editing the right php.ini file because I have another extension added (wincache) and it is loading fine, confirmed with both phpinfo() and get_loaded_extensions() . 我知道我正在编辑正确的php.ini文件,因为我添加了另一个扩展名(wincache),它正在加载正常,同时使用phpinfo()get_loaded_extensions()

The logs aren't telling me anything. 日志没有告诉我任何事情。 PHP Manager on IIS is telling me that the sqlsrv extension files are enabled. IIS上的PHP管理器告诉我sqlsrv扩展文件已启用。 I've restarted the website, the server, and the computer, and nothing's working. 我重新启动了网站,服务器和计算机,但没有任何工作。

I'm using PHP 7.1.1 on a Windows 7 Ultimate machine. 我在Windows 7 Ultimate机器上使用PHP 7.1.1。 It's running in x64 mode, Non-Thread Safe. 它以x64模式运行,非线程安全。 I've made sure that the extension files I enabled are the x64, non-thread-safe ones. 我确保我启用的扩展文件是x64,非线程安全的。 I don't know what else to check or what more info I need to provide. 我不知道还有什么要检查或我需要提供更多信息。

EDIT: I ran php-cgi.exe as this page suggested, and it came out with the error mesages: 编辑:我按照此页面建议运行php-cgi.exe cgi.exe,它出现了错误消息:

[31-Mar-2017 22:38:12 UTC] PHP Warning:  PHP Startup: Unable to load dynamic library 'C:\Program Files\iis express\PHP\v7.1\ext\php_sqlsrv_7_nts_x64.dll' - The specified procedure could not be found.
 in Unknown on line 0
[31-Mar-2017 22:38:17 UTC] PHP Warning:  PHP Startup: Unable to load dynamic library 'C:\Program Files\iis express\PHP\v7.1\ext\php_pdo_sqlsrv_7_nts_x64.dll' - The specified procedure could not be found.
 in Unknown on line 0

Does this mean that the problem is in the extension DLLs themselves? 这是否意味着问题出在扩展DLL本身? How would I even go about fixing that? 我怎么会去解决这个问题呢?

EDIT 2: ImClarky nailed the problem in that I was apparently using a way outdated version of the extension. 编辑2: ImClarky解决了这个问题,因为我显然使用了一个过时的扩展版本。 I've got it working, but now my authentication is failing for reasons I don't understand: 我已经有了它的工作,但现在我的身份验证失败的原因我不明白:

function connect_sql() {
    /* Specify server and connection attributes */
    $serverName = "(local)";

    /* Get UID and PWD from app-specific files */
    $uid = file_get_contents("C:\AppData\uid.txt");
    $pwd = file_get_contents("C:\AppData\pwd.txt");
    $connectionInfo = array("UID" => $uid,
                            "PWD" => $pwd,
                            "Database" => "database_name");

    /* Connect using SQL Server Auth */
    $conn = sqlsrv_connect($serverName, $connectionInfo);
    if ($conn === false)
    {
        echo "Unable to connect.</br>";
        //die(print_r(sqlsrv_errors(), true));
        die(print_errors());
    }
    else {
        echo "Connection Successful";
    }

    /* Free connection resources */
    sqlsrv_close($conn);
}

I've double checked that I am using the correct username and password, and I even went in and created an entirely new login using the exact UID and password I'm trying. 我已经仔细检查过我使用了正确的用户名和密码,我甚至进入并使用我正在尝试的确切UID和密码创建了一个全新的登录。 I still get the following error message every time: 我每次仍然收到以下错误消息:

Unable to connect.

SQLSTATE: 28000
code: 18456
message: [Microsoft][ODBC Driver 13 for SQL Server][SQL Server]Login failed for user 'username'.

SQLSTATE: 28000
code: 18456
message: [Microsoft][ODBC Driver 13 for SQL Server][SQL Server]Login failed for user 'username'.

Make sure you add .dll file for extension folder used by php.ini 确保为php.ini使用的扩展文件夹添加.dll文件

Also chose correct driver of SQLSRv matched your running PHP 还选择了正确的SQLSRv驱动程序与您运行的PHP相匹配

SQLSRv sqlsrv from official microsoft page 来自官方微软页面的 SQLSRv sqlsrv

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM