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.

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

报告相同问题?

悬赏问题

  • ¥88 找成都本地经验丰富懂小程序开发的技术大咖
  • ¥15 如何处理复杂数据表格的除法运算
  • ¥15 如何用stc8h1k08的片子做485数据透传的功能?(关键词-串口)
  • ¥15 有兄弟姐妹会用word插图功能制作类似citespace的图片吗?
  • ¥200 uniapp长期运行卡死问题解决
  • ¥15 请教:如何用postman调用本地虚拟机区块链接上的合约?
  • ¥15 为什么使用javacv转封装rtsp为rtmp时出现如下问题:[h264 @ 000000004faf7500]no frame?
  • ¥15 乘性高斯噪声在深度学习网络中的应用
  • ¥15 关于docker部署flink集成hadoop的yarn,请教个问题 flink启动yarn-session.sh连不上hadoop,这个整了好几天一直不行,求帮忙看一下怎么解决
  • ¥15 深度学习根据CNN网络模型,搭建BP模型并训练MNIST数据集