简体   繁体   中英

PDO Not Found on Windows Server 2012 R2 and PHP 5.6.4

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?

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM