SQLSRV PHP for SQL Server for is not a valid Win32 application

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/22530231/
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 16:05:26  来源:igfitidea点击:

SQLSRV PHP for SQL Server for is not a valid Win32 application

phpsql-serverapachesqlsrv

提问by iltdev

Here is my setup

这是我的设置

  • Windows Server 2008 R2 64 bit
  • Apache 2.4.4 64 bit
  • PHP 5.4.15 32 bit (64 bit is still experimental), thread safe, VC9 compiler
  • Microsoft SQL Server 2012 Native Client 64-bit
  • Microsoft Visual C++ 2010 x86 and x64
  • Windows Server 2008 R2 64 位
  • Apache 2.4.4 64 位
  • PHP 5.4.15 32 位(64 位仍处于试验阶段),线程安全,VC9 编译器
  • Microsoft SQL Server 2012 本机客户端 64 位
  • Microsoft Visual C++ 2010 x86 和 x64

I need to load Microsoft's SQLSRV library.

我需要加载 Microsoft 的 SQLSRV 库。

I have added 'extension=php_sqlsrv_54_ts.dll' to php.ini and copied 'php_sqlsrv_54_ts.dll' to the ext folder where PHP is installed.

我已将“extension=php_sqlsrv_54_ts.dll”添加到 php.ini 并将“php_sqlsrv_54_ts.dll”复制到安装 PHP 的 ext 文件夹中。

When I restart apache, I get the following error in my php error log, and SQLSRV is not listed in phpinfo.

当我重新启动 apache 时,我的 php 错误日志中出现以下错误,并且 phpinfo 中未列出 SQLSRV。

PHP Warning:  PHP Startup: Unable to load dynamic library 'C:\php5\ext\php_sqlsrv_54_ts.dll' - %1 is not a valid Win32 application.

Where am I going wrong?

我哪里错了?

EDIT For testing purposes I've just installed PHP 5.5.10 64 bit and VC 2012 but the error remains the same :(

编辑出于测试目的,我刚刚安装了 PHP 5.5.10 64 位和 VC 2012,但错误仍然相同:(

采纳答案by AdRock

I don't know if it helps but i used all 32bit on my Windows 7 64bit system

我不知道它是否有帮助,但我在 Windows 7 64 位系统上使用了所有 32 位

Here is what I used and i can use SQL Server

这是我使用的,我可以使用 SQL Server

httpd-2.4.6-win32-VC9 //apache 2.4
php-5.4.9-Win32-VC9-x86 //php5

inside if my \php\folder i have

里面如果我的\php\文件夹我有

  • php5apache2_4.dll
  • php5apache2_4.dll

Inside \php\ext\i have

里面\php\ext\我有

  • php_pdo_sqlsrv_54_nts.dll
  • php_pdo_sqlsrv_54_ts.dll
  • php_pdo_sqlsrv_54_nts.dll
  • php_pdo_sqlsrv_54_ts.dll

I added this to the end of php.ini

我将此添加到 php.ini 的末尾

[PHP_SQLSRV]
extension=php_sqlsrv_54_ts.dll
[PHP_PDO_SQLSRV]
extension=php_pdo_sqlsrv_54_ts.dll

I remember it being a right pain getting it to work but it does now. If i remember anymore i'll edit my answer

我记得让它工作是一种正确的痛苦,但现在确实如此。如果我再记得我会编辑我的答案

UPDATE:

更新:

I think this blog post looks familiar on how i got it working

我认为这篇博文看起来很熟悉我是如何让它工作的

http://robsphp.blogspot.co.uk/2012/09/how-to-install-microsofts-sql-server.html

http://robsphp.blogspot.co.uk/2012/09/how-to-install-microsofts-sql-server.html

回答by anil gangwal

currently Microsoft sqldriver only works for 32bit php version. Here is my steps to install sql drivers.

当前 Microsoft sqldriver 仅适用于 32 位 php 版本。这是我安装sql驱动程序的步骤。

回答by Tschallacka

I had the same issue. Running a legacy 5.6 php x64 which needed the interface because of the hard RAM restrictions 32 bits give.

我遇到过同样的问题。运行传统的 5.6 php x64 需要接口,因为 32 位给出了硬 RAM 限制。

The solution was in the unoffical driver offered by Rob.

解决方案是在 Rob 提供的非官方驱动程序中。

https://robsphp.blogspot.nl/2012/06/unofficial-microsoft-sql-server-driver.html

https://robsphp.blogspot.nl/2012/06/unofficial-microsoft-sql-server-driver.html

I tested it out, and it works properly with 5.6.33 x64

我测试了它,它在 5.6.33 x64 下正常工作

回答by lisandro

Sqlsrv requires php x86. This message appears when php is 64 bit architecture.

Sqlsrv 需要 php x86。当 php 是 64 位架构时会出现此消息。