Strange PDO error

Hi guys

i have two pdo connection file as follows

  1. public_html/includes/pdo_connection.php
  2. public_html/new_system/includes/pdo_connection.php

both of the pdo_connection.php files are identical.
problem is first works, but not the second one.

Fatal error: Class ‘PDO’ not found in /home/fazihuz3/public_html/ on line 13

What could be wrong? i have put the file contents below .

/*** mysql hostname ***/ 
$hostname = 'localhost'; 
/*** mysql username ***/ 
$username = 'fazihuz3_zamaan'; 
/*** mysql password ***/ 
$password = 'some_password'; 
try { 
    $db = new PDO("mysql:host=$hostname;dbname=fazihuz3_stats", $username, $password); 
    /*** echo a message saying we have connected ***/ 
    //echo 'Connected to database';  
    // Throw exceptions on errors 
    // Use assoc arrays by default 
    array(PDO::MYSQL_ATTR_INIT_COMMAND => 'SET time_zone = \'+03:00\'')    ; 
}catch(PDOException $e){ 
    echo $e->getMessage(); 
//this is a must for saving and retrving utf-8 (arabic) charactors to db// 
$query = $db->query("SET NAMES 'utf8'"); 

This error has nothing to do with your code. PDO is a built-in PHP class and in case it is not found, it is not configured for your new system web-server. It should be enabled in php.ini. To verify, you can run phpinfo() in your new system and see if you can find PDO mentioned on the page.

The only other possibility is that your new system is using namespaces and in this case you should address PDO as \PDO.

1 Like

HI colshrapnel,

i just did a phpinfo on that dir and i can see these

Configure Command :


Thank you

i also got some apache error log when running the script having the pdo connection.

Fri Sep 23 04:14:38 2016] [error] [client] Cannot load the ionCube PHP Loader - it was built with configuration API220090626,NTS, whereas running engine is API220100525,NTS, referer:
[Fri Sep 23 04:14:38 2016] [error] [client] Zend Guard Loader requires Zend Engine API version 220090626., referer:
[Fri Sep 23 04:14:38 2016] [error] [client] The Zend Engine API version 220100525 which is installed, is newer., referer:
[Fri Sep 23 04:14:38 2016] [error] [client] Contact Zend Technologies at for a later version of Zend Guard Loader., referer:
[Fri Sep 23 04:14:38 2016] [error] [client] , referer:

Open up your php.ini file and search for:


If there’s a ; at the start of that line, remove the ; then save the changes. You’ll then need to restart the server for the changes to take affect

1 Like

Hi buddy,

Thank you for the tip. but mean time my managed server provider had managed to solve the issue. this is what they said.

The issue has now been resolved.

On checking, I could see that you have been using some custom setup to
load PHP config files from the location
/var/lib/php/liberal/fazihuz3/php.ini which did not have PDO class
listed in its modules and this is why you ended up in the error.

I renamed the location so that the default PHP configs are loaded from /usr/local/lib/php.ini.

Thank you every for the replies. really appreciate it…

This worked and the sites display the PDO connection just fine. :slight_smile:

1 Like

This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.