3

I'm getting this error after upgrading PHP to 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:

$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

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.dll in [PHP] section of php.ini

  3. Rebooted IIS and also rebooted server itself.

  4. Downgraded PHP to 5.3.27

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

4
  • Put <?php phpinfo() ?> in a test php script, open in your browser. See if the "com_dotnet" section is there and if "COM support" is "enabled." Commented Aug 14, 2013 at 19:53
  • Out of curiosity, why are you using ADO when you could use PHP's mssql SQL Server client library? Commented Aug 14, 2013 at 20:22
  • @Dai - I don't know much about php so I used sqlmaestro's php generator for MSSQL database. Commented Aug 14, 2013 at 20:45
  • @jszobody - The only reference to com_dotnet I see is in Configure Command section: cscript /nologo configure.js "--enable-snapshot-build" "--enable-debug-pack" "--disable-zts" "--disable-isapi" "--disable-nsapi" "--without-mssql" "--without-pdo-mssql" "--without-pi3web" "--with-pdo-oci=C:\php-sdk\oracle\instantclient10\sdk,shared" "--with-oci8=C:\php-sdk\oracle\instantclient10\sdk,shared" "--with-oci8-11g=C:\php-sdk\oracle\instantclient11\sdk,shared" "--with-enchant=shared" "--enable-object-out-dir=../obj/" "--enable-com-dotnet=shared" "--with-mcrypt=static" "--disable-static-analyze Commented Aug 14, 2013 at 20:54

1 Answer 1

3

In addition to adding

[PHP_COM_DOTNET]
extension=php_com_dotnet.dll

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

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

extension_dir = "ext"

To enable extensions set the enable flag to On:

enable_dl = On
Sign up to request clarification or add additional context in comments.

1 Comment

OP probably might NOT want to enable_dl = on , as he uses IIS, and php.ini says: The dl() function does NOT work properly in multithreaded servers, such as IIS or Zeus, and is automatically disabled on them.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.