0

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?

aallord
  • 1
  • 2
  • Try searching on Stack Overflow for some questions like http://stackoverflow.com/questions/7086859/pdo-drivers-no-value-in-windows – floor Feb 23 '15 at 22:11
  • As that refers to "no drivers" I have drivers and they are running as explained in my question. – aallord Feb 23 '15 at 22:14
  • Sorry I missed the end part. I don't know much about windows server config but have you followed these instructions http://php.net/manual/en/pdo.installation.php ? You may have missed the part where it says PDO for specific db options --> http://php.net/manual/en/pdo.drivers.php – floor Feb 23 '15 at 22:18
  • Yes, those instructions are followed... Again, this is not installation as indicated the drivers are there, the PDO class exists... The error is generated from the first code block where dbConnect() is called.. – aallord Feb 23 '15 at 22:21
  • Alright, here is a link to proper syntax http://php.net/manual/en/ref.pdo-dblib.php Scroll to second entry. – floor Feb 23 '15 at 22:22
  • This was MySQL, not SQL Server. As pointed in my answer below, I inadvertently had a 0 (zero) where it should of been the letter O. – aallord Feb 23 '15 at 22:30
  • bahahah what a crappy error – floor Feb 23 '15 at 22:30

1 Answers1

0

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.

aallord
  • 1
  • 2