PHP 致命错误:找不到“COM”类

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

PHP Fatal error: Class 'COM' not found

phpwindowsiis-7

提问by user1060641

I'm getting this error after upgrading PHP to v. 5.5.1:

将 PHP 升级到 v. 5.5.1 后出现此错误:

Fatal error: Class 'COM' not found in
C:\inetpub\wwwroot\ndsystems\database_engine\mssql_engine.php on line 184

Line 184 in mssql_engine.php file:

mssql_engine.php 文件中的第 184 行:

$this->COMConnection = new COM('ADODB.Connection');    //line 184
try {
    $this->COMConnection->Open($connectionString);
    $this->RetrieveServerVersion();
} catch (com_exception $e) {
    $this->lastError = $e->getMessage();
    $result = false;
}
return $result;

Environment is Windows 2008 R2 SP1, IIS 7

环境是Windows 2008 R2 SP1,IIS 7

Things I tried:

我尝试过的事情:

  1. Added this at the end of php.ini:

    [PHP_COM_DOTNET]
    
    extension=php_com_dotnet.dll
    
  2. Added extension=php_com_dotnet.dllin [PHP] section of php.ini

  3. Rebooted IIS and also rebooted server itself.

  4. Downgraded PHP to 5.3.27

  1. 在 php.ini 的末尾添加了这个:

    [PHP_COM_DOTNET]
    
    extension=php_com_dotnet.dll
    
  2. extension=php_com_dotnet.dll在 php.ini 的 [PHP] 部分添加

  3. 重新启动 IIS 并重新启动服务器本身。

  4. 将 PHP 降级到 5.3.27

Nothing seems to work. How do I fix this error?

似乎没有任何效果。我该如何解决这个错误?

回答by CallMeHarmon

In addition to adding

除了添加

[PHP_COM_DOTNET]
extension=php_com_dotnet.dll

to your php.inifile, you have to tell PHP where to look for the extension, and to enable extensions.

对于您的php.ini文件,您必须告诉 PHP 在哪里查找扩展名,并启用扩展名。

To tell PHP where to look for extensions on Windows just uncomment (remove the leading ;) following line:

要告诉 PHP 在哪里查找 Windows 上的扩展,只需取消注释(删除前导;)以下行:

extension_dir = "ext"

To enable extensions set the enable flag to On:

要启用扩展,请将启用标志设置为开:

enable_dl = On