致命错误:在PHP 5.6中找不到类'COM'

时间:2017-06-12 20:05:18

标签: php linux ms-access webserver

我有多个MS Access数据库放在Linux Web服务器上,由GoDaddy托管。但是当我尝试通过我的登录门户登录时,它会给我一个错误:致命错误:第11行的/home/buerer/public_html/flames/events/checklogin.php中找不到类'COM'

这是checklogin.php文件的代码:

<?php
session_start();
ini_set('display_errors', 1); error_reporting(E_ALL);
global $rs;
// parse username and password sent from signup form post to php variables
$myusername=$_POST['myusername']; 
$mypassword=$_POST['mypassword']; 
$access = realpath("db/users.mdb");
$_SESSION['accessLevel'] = "READ DATA FROM TABLE";
//create connection as COM object
$conn = new COM('ADODB.Connection') or exit('Cannot start ADO.');
//create recordset as new COM object
$rs = new COM('ADODB.Recordset')  or exit('Cannot create recordset.');
//dim connection with driver and password
  $conn->Open("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=$access;Jet OLEDB:Database Password='softball1234';");
//$conn->Open("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=$access;Jet OLEDB:Database Password=$mypassword;");
$sql = "SELECT * FROM tblUsers WHERE VendorCode='$myusername' and Password='$mypassword'";
//execute sql in connection to database to store are recordset
$rs = $conn->Execute($sql);


if ($rs->EOF) {
        echo "Wrong Username or Password";
        print "<br>Click <a href=main_login.php>here</a> to try again.";

  //print $rs->ErrorMsg(); // Displays the error message if no results could be returned
}else{
        $_SESSION['AccessLevel'] = $rs->fields["AccessLevel"]->value;
        $_SESSION['MailingListID'] = $rs->fields["MailingListID"]->value;
        $count = 0;
    while (!$rs->EOF) { 
        $count++;
        $rs->MoveNext();
     } //while !$rs->eof

    if($count>0){
        // Register $myusername, $mypassword and AccessLevel and redirect to file "selection.php"
        $_SESSION['username'] = $myusername;
        $_SESSION['password'] = $mypassword;


        //$_SESSION['AccessLevel'] = $rs->fields["AccessLevel"]->value;

        header("location:selection.php");
    }else {

        echo "Wrong Username or Password";
        print "<br>Click <a href=main_login.php>here</a> to try again.";
        session_destroy();
        }
}
?>

我在GoDaddy文件管理器中找不到php.ini文件,有人知道如何解决这个问题吗?

1 个答案:

答案 0 :(得分:0)

从PHP 5.4.5开始,COM和DOTNET不再内置到php核心中。你必须在php.ini中添加COM支持:

[COM_DOT_NET] 延长= php_com_dotnet.dll 否则,您将在错误日志中看到此信息:致命错误:Class&#39; COM&#39;找不到