dsa5211314 2015-02-23 22:08
浏览 69
已采纳

在Windows Server 2012 R2和PHP 5.6.4上找不到PDO

I am trying to connect using PDO on a Windows Server 2102 R2 running Apache 2.4.10 and PHP 5.6.4 from a script and get the error "Class 'PDO' not found" when trying to connect.

Here is the code calling the connection

ini_set('display_errors', 'On');
require_once('c:/path/site_inc.php');

switch($_REQUEST['action']){
    case 'getList':
        getList();
        break;
}
function getList(){
    $dbh = dbConnect();
    $pstmt = $dbh->prepare("SELECT * FROM announcements WHERE user=? ORDER BY startDate");
    $pstmt->execute(array($_COOKIE['appsuname']));
    echo json_encode($pstmt->fetchAll(PD0::FETCH_ASSOC));
}

function dbConnect(){
    $DBH = new PDO(ccappConfig::mysqlDSN, ccappConfig::mysql_user, ccappConfig::mysql_pword);
    return $DBH;
}

I have tested to make sure PDO is available in the following manner

if(class_exists('PDO')){
    echo "PDO Installed<br />";
} else {
    echo "PDO NOT Installed<br />";
}
phpinfo();

This returns "PDO Installed" and the phpinfo() confirms pdo_mysql is installed along with both mysql (being eliminated) and mysqli.

I am not sure why this error is generated and php_pdo.dll has been eliminated from 5.3 forward with PHP so I don't believe I am missing a driver and I also don't believe this due to the phpinfo() returning under PDO heading both mysql and sqlite drivers are enabled.

What am I missing here or is there something wrong with my code I am missing?

  • 写回答

1条回答 默认 最新

  • doufei2007 2015-02-23 22:26
    关注

    I found the error here

    function getList(){
    $dbh = dbConnect();
    $pstmt = $dbh->prepare("SELECT * FROM announcements WHERE user=? ORDER BY startDate");
    $pstmt->execute(array($_COOKIE['appsuname']));
    echo json_encode($pstmt->fetchAll(PD0::FETCH_ASSOC));
    

    }

    The above code should be

    function getList(){
    $dbh = dbConnect();
    $pstmt = $dbh->prepare("SELECT * FROM announcements WHERE user=? ORDER BY startDate");
    $pstmt->execute(array($_COOKIE['appsuname']));
    echo json_encode($pstmt->fetchAll(PDO::FETCH_ASSOC));
    

    }

    The first block was 0 (zero) and not O.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥20 腾讯企业邮箱邮件可以恢复么
  • ¥15 有人知道怎么将自己的迁移策略布到edgecloudsim上使用吗?
  • ¥15 错误 LNK2001 无法解析的外部符号
  • ¥50 安装pyaudiokits失败
  • ¥15 计组这些题应该咋做呀
  • ¥60 更换迈创SOL6M4AE卡的时候,驱动要重新装才能使用,怎么解决?
  • ¥15 让node服务器有自动加载文件的功能
  • ¥15 jmeter脚本回放有的是对的有的是错的
  • ¥15 r语言蛋白组学相关问题
  • ¥15 Python时间序列如何拟合疏系数模型