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.

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

报告相同问题?

悬赏问题

  • ¥15 乌班图ip地址配置及远程SSH
  • ¥15 怎么让点阵屏显示静态爱心,用keiluVision5写出让点阵屏显示静态爱心的代码,越快越好
  • ¥15 PSPICE制作一个加法器
  • ¥15 javaweb项目无法正常跳转
  • ¥15 VMBox虚拟机无法访问
  • ¥15 skd显示找不到头文件
  • ¥15 机器视觉中图片中长度与真实长度的关系
  • ¥15 fastreport table 怎么只让每页的最下面和最顶部有横线
  • ¥15 R语言卸载之后无法重装,显示电脑存在下载某些较大二进制文件行为,怎么办
  • ¥15 java 的protected权限 ,问题在注释里