PHP and ADODB connection fail

2020-05-01 04:21发布

问题:

I have been tasked to migrate servers. This includes moving over apps I did not build, a couple of which have an ADODB.connection that I cannot seem to fix on the new servers (I only get blank screens).

I have researched quite extensively ADODB.connection with PHP and cannot find a definite source. Most are related to VB Script, or even Excel documents. I even searched YouTube and the only thing I found wasn't even in English.

I took some of the previous developer's code and created a test.php:

<?php
  error_reporting(E_ALL);
  ini_set('display_errors', 1);

  // echo 'hello' <-- I can show this to the page
  $Conn = New COM("ADODB.Connection");
  // echo 'hello again' <-- this will not show
  $RS = New COM("ADODB.Recordset");

  $Conn->Provider = "ADsDSOObject";
  $Conn->Properties['User ID'] = "her.something@something.com";
  $Conn->Properties['Password'] = "password";
  $strConn = "Active Directory Provider";
  $Conn->Open($strConn);
?>

As you will see in the code above, I obviously can echo 'hello' before the $conn variable. Nothing works after the $conn variable.

I have no familiarity with ADODB.connection or Active Directory.

How can I test this code if I cannot even echo anything after the $conn variable? What am I missing? What can I add?

I do not see anything relating to ADODB in the phpinfo. The closest is ODBC, which is included.

Edit

I just added the 2 additional lines as requested by @Hackerman.

Here are the errors the page is displaying:

Deprecated: mysql_connect(): The mysql extension is deprecated and will be removed in the future: use mysqli or PDO instead in D:\htdocs\application1\include\database.php on line 25

Deprecated: mysql_connect(): The mysql extension is deprecated and will be removed in the future: use mysqli or PDO instead in D:\htdocs\application1\include\database.php on line 28

Deprecated: Function mysql_numrows() is deprecated in D:\htdocs\application1\include\database.php on line 226

Deprecated: Function mysql_numrows() is deprecated in D:\htdocs\application1\include\database.php on line 237

Deprecated: Function mysql_numrows() is deprecated in D:\htdocs\application1\include\database.php on line 100

Deprecated: Function mysql_numrows() is deprecated in D:\htdocs\application1\include\database.php on line 180

Deprecated: Function mysql_numrows() is deprecated in D:\htdocs\application1\include\database.php on line 226

Deprecated: Function mysql_numrows() is deprecated in D:\htdocs\application1\include\database.php on line 226

Deprecated: Function mysql_numrows() is deprecated in D:\htdocs\application1\include\database.php on line 237

Fatal error: Class 'COM' not found in D:\htdocs\application1\admin\test.php on line 8

The previous developer was indeed using MySQL instead of mysqli or PDO, which explains the deprecated errors.

I'm hoping the last error sheds light on the ADODB problem at hand.

Edit 2

Installed the php_com_dotnet.dll file into the extension folder and included the file on the php.ini file and got the following error:

Fatal error: Uncaught exception 'com_exception' with message 'Failed to create COM object `ADODB.Connection': The specified module could not be found. ' in D:\htdocs\application1\admin\test.php:8 Stack trace: #0 D:\htdocs\application1\admin\test.php(8): com->com('ADODB.Connectio...') #1 {main} thrown in D:\htdocs\application1\admin\test.php on line 8