Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

Rretzko's avatar
Level 15

PDO File not found on seven year old app....

Hi Folks - I have a php application that I wrote six years ago from scratch. I haven't touched the code base for at least four years and it has been running as expected. It is now giving me a 500 error with the message:

HP Fatal error:  Uncaught Error: Class "PDO" not found in public_html/rhschoirs.net/dbs/db.php:120

Line 120 of this file is:

I'm now searching for an old backup copy to test on and I've tried to just drop in a copy of PDO.php from the php site into the /dbs directory but that didn't change anything. Any thoughts on this are appreciated! Rick

0 likes
3 replies
LaryAI's avatar
Level 58

It looks like your PHP application is throwing a fatal error because it cannot find the PDO class. This typically happens when the PDO extension is not enabled in your PHP configuration. Here are the steps you can take to resolve this issue:

  1. Check if PDO is installed and enabled:

    • Create a PHP file (e.g., phpinfo.php) with the following content:
      <?php
      phpinfo();
      ?>
      
    • Access this file through your web browser. Look for a section titled PDO. If you don't see it, then PDO is not enabled.
  2. Enable the PDO extension:

    • Open your php.ini file. The location of this file can vary depending on your server setup. Common locations include /etc/php.ini, /etc/php/7.4/apache2/php.ini, or /etc/php/7.4/cli/php.ini.
    • Look for the following lines and make sure they are not commented out (remove the ; at the beginning of the line if it exists):
      extension=pdo.so
      extension=pdo_mysql.so
      
    • If these lines are not present, add them.
  3. Restart your web server:

    • After making changes to php.ini, you need to restart your web server for the changes to take effect. The command to restart the server depends on the server software you are using. For example:
      • For Apache:
        sudo systemctl restart apache2
        
      • For Nginx with PHP-FPM:
        sudo systemctl restart php7.4-fpm
        sudo systemctl restart nginx
        
  4. Verify the changes:

    • Reload the phpinfo.php file in your browser and check if the PDO section is now present.
  5. Check for syntax errors:

    • Ensure there are no syntax errors in your db.php file. The code you posted seems to have a typo in the test system credentials:
      $user = 'rhs*****'; // Correct the typo here
      $pw = '*************'; // Correct the typo here
      

Here is the corrected version of your connect_To_My_Sql_Database function:

By following these steps, you should be able to resolve the Class "PDO" not found error and get your application running again.

MohamedTammam's avatar

Are you hosting your project in shared hosting or custom VPS?

2 likes
jlrdw's avatar

Also there would be security issues in such an older app. Do you lookup the various security articles for php, laravel, and any packages you use.

You should be getting daily or at least weekly update articles.

2 likes

Please or to participate in this conversation.