I installed my website and it was working just fine, today all of a sudden i am getting this message... i don't want to reinstall the website again and i can't get it over

PLEASE HELP!

Fatal error: Class 'PDO' not found in /home/liveaq5/public_html/juwsc/includes/database/database.inc on line 185

website: www.juwsc.org

Comments

Jaypan’s picture

It sounds like maybe the PDO extension isn't installed in your PHP. Are you using shared hosting? Maybe they recompiled PHP and left that extension out for some reason? Try contacting them and asking.

sw3b’s picture

Run phpinfo on your server to see if you have PDO enable, if so add this in your php.ini if you are on shared hosting. This solve my problem on my side !

extension="pdo.so"
extension="pdo_mysql.so"

After thoses lines put your setting you need for max upload file, etc. if you need some.

RdeBoer’s picture

Thanks so much sw3!
I had exactly this problem with a client using shared hosting.
In D6 you could just put "memory_limit=128M" in your php.ini and put the php.ini file in the web root, i.e. the same directory that index.php lives in.
In D7, as you pointed out, you need to put these 2 lines in front of it:

--------------------------- php.ini ---------------------
extension="pdo.so"
extension="pdo_mysql.so"

memory_limit=128M
---------------------------------------------------------

Really these 2 top lines should be part of the standard D7 core distribution don't we think?

Thanks again,
The hosting company couldn't help me, but you did!

Rik

mostoneskin’s picture

Had this issue as I needed to up my upload limits, created a php.ini and the site woulnt' load. Googled the error and hit this thread. All sorted within 5 minutes, but why waste 5 minutes? If on the whole Drupal installations require these settings then at least a sample/recommended php.ini would be good!

intcomtech’s picture

Thank you so much RdeBoer. I had a php.ini file uploaded to my site but despite enabling pdo.so and pdo_mysql.so, yet the problem persisted.
However, I decided to delete everything and just paste the three line of codes as you gave them. Bammmmm! It worked like magic. My site is now up and running. Thnks a Million. Cheers

gggdrpl’s picture

Thanks a lot sw3b!!!

kastorino’s picture

I am sorry, but I don't understand where should I put that code. i'm on a shared hosting, and i cannot modify the php.ini file.

gggdrpl’s picture

You can try uploading your own php.ini file in the root directory of your Drupal installation. Most of shared hosting servers will let you do that!!!

danikkp’s picture

How to run phpinfo? Thanks!

pauloamgomes’s picture

You need to create an php file inside your web server (ex: /www_root/get-php-info.php), and put inside the following line of code :

print phpinfo();

and go to url: http:///get-php-info.php

you should get the output of phpinfo() command with php related configurations.

theliondog’s picture

Hi sw3b

Thanks mate. I had the same issue and you fixed that one! Unfortunately I also have others.

Very happy with my 'local' version of drupal, so I installed Drupal 7 from 'fantastico' through cPanel on my remote server, and then imported mySQL database. The site recognised the data but the 'appearance' was from a "stark" theme, not the standard Bartic which I thought odd. My local installation used a sub zen theme, so I overwrote the remote 'sites' folder with my local 'sites' folder (making sure the 'settings.php' matched the database log in etc).

This install still hadthe stark appearance, and I deleted the fantastico version, and ftp'd my full local installation, and also re-installed the database.

The data is being sourced, but for some reason, the theme is not being recognised, and I'm getting a "stark" kind of theme with no css reference from the sub zen files. Also getting a
Warning: file_put_contents(temporary://fileHjM1Q7) [function.file-put-contents]: failed to open stream: "DrupalTemporaryStreamWrapper::stream_open" call failed in file_unmanaged_save_data() (line 1847 of /home/xxxxx/public_html/includes/file.inc).

I've been searching threads of all kinds, so hope I haven't missed something obvious for the latest. This is kind of urgent and I've been on it for a while, so any help would be greatly appreciated!!
Thanks in advance
tld

dadderley’s picture

thanks

supawebs’s picture

Fixed my problem. Thank you.

xtream’s picture

SW3B - Thanks so much for providing this information. I've been trying to change the php.ini in my shared hosting (GreenGeeks) to increase the upload file size, but I always got the Fatal Error PDO...

Once I added the two extension that you recommended the php.ini worked fine. I also verified the phpinfo and it looks fine too.

So for the benefit of the noobies that are using the GreenGeek hosting here is the php.ini that will work with Drupal 7.

register_globals = Off

extension="pdo.so"
extension="pdo_mysql.so"

memory_limit=256M

post_max_size = 250M
upload_max_filesize = 250M
upload_tmp_dir = 150M
max_execution_time = 180

:)

Mackee’s picture

I've been using Drupal for quite some time and haven't encountered this issue on all the servers I used, untill now.

Thanks sw3b!

pendashteh’s picture

I'm using a shared hosting. It seems the PHP is compiled with pdo disabled:

my phpinfo() says:

Configure Command:
'./configure' '--disable-pdo' '--enable-bcmath' '--enable-calendar' '--enable-exif' '--enable-ftp' '--enable-gd-native-ttf' '--enable-libxml' '--enable-magic-quotes' '--enable-mbstring' '--enable-soap' '--enable-sockets' '--enable-zip' '--prefix=/usr' '--with-curl=/opt/curlssl/' '--with-curlwrappers' '--with-freetype-dir=/usr' '--with-gd' '--with-gettext' '--with-imap=/opt/php_with_imap_client/' '--with-imap-ssl=/usr' '--with-jpeg-dir=/usr' '--with-kerberos' '--with-libexpat-dir=/usr' '--with-libxml-dir=/opt/xml2' '--with-libxml-dir=/opt/xml2/' '--with-mcrypt=/opt/libmcrypt/' '--with-mm=/opt/mm/' '--with-mysql=/usr' '--with-mysql-sock=/var/lib/mysql/mysql.sock' '--with-mysqli=/usr/bin/mysql_config' '--with-openssl=/usr' '--with-openssl-dir=/usr' '--with-pcre-regex=/opt/pcre' '--with-png-dir=/usr' '--with-ttf' '--with-xmlrpc' '--with-xpm-dir=/usr' '--with-xsl=/opt/xslt/' '--with-zlib' '--with-zlib-dir=/usr' 

It means this is not a mistake of hosting owner, but he has disabled PDO by decision; so the pho.ini solution won't work.

and at the code we see drupal has extended class PDO:

abstract class DatabaseConnection extends PDO {

So is there any code-written replacement for class PDO? or any other solution?

vikas.konsam@gmail.com’s picture

I am having the same problem as takpar.

Does anyone have a solution to this?

pauloamgomes’s picture

I was just searching google for same problem here.., in my case I'm using anhosting and site stops working without any change in Drupal code.
After adding the pdo extension lines to php.ini inside drupal root folder as described in comments, all back to normal, many thanks.

kamaldrupal’s picture

where is the php.ini file ,,what code?
please explain me in detail.

sjugge’s picture

- create a blank file in your drupal or server root named 'phpinfo.php'
- add the following code into the file

<?php
phpinfo();
?>

- go to the file via a browser, e.g. yoursite.com/phpinfo.php
- look (ctrl/cmd + F) for the 'Configuration File (php.ini) Path', you'll find the location of your php.ini file there

If you are unable to acces this through FTP/cPanel/..., create a file named php.ini in your drupal root folder and add the following lines of code:

extension="pdo.so"
extension="pdo_mysql.so"
upload_max_filesize = 10M
post_max_size =64M
memory_limit = 64M
upload_tmp_dir = 64M
max_execution_time = 128

note that you may want to tweak these values depending on your needs.

Nunique’s picture

Ok have done the phpinfo.php file and uploaded it found the php.ini file but unable to access it via ftp/cpanel, then went the route to create a new php.ini file with the info contained in the post above - and uploaded it to the drupal root folder and am still getting the same error message.

Please let me know if there is something else I need to be doing that I am not doing.

Thanks a mil.

sjugge’s picture

Try putting in higher values, I've given rather minimal values in the example above which might just be sufficient for the minimum requirements for core to run.

mhamed’s picture

i ve got the same problem:

Fatal error: Class 'PDO' not found in /home/user/public_html/includes/database/database.inc on line 184

the extenssions pdo exist in my php.ini i ve got a php version 5.3
set in .htaccess like this:

SetEnv PHPRC 
/home/wordtosa/public_html/php.ini 
AddHandler php5_3-wrap .php

but the error persist.
I tried to delet php.ini file form my public_html/
And the site gone on
i m trying to find why:

pradhanrak91’s picture

Your six year old comment just saved me! thanks a lot!

sjugge’s picture

I've spend the last day going through documentation on d.o, my hosting provider and pretty much all over the place in order to get images to render properly on my site by dropping a custom php.ini file in my drupal root folder. I had been banging my head on my desk until I found these two lines of code and things are humming smoothly now :)

Thanks a bunch for sharing this!

I'll add it to my hosting providers documentation and see if I can add it to the documentation on d.o somehow, I suspect more people have stared themselves blind on this.

fatiharchitecture’s picture

thanks all, but sjugge explain step by step very thanks...

lesreaper’s picture

I had to contact GreenGeeks for a solution. This is the extra 2 lines of code for the custom php.ini file I dropped in my public.html folder:

register_globals = Off
extension="pdo.so"
extension="pdo_mysql.so"
memory_limit=128M
extension_dir = "/usr/local/lib/php/extensions/no-debug-non-zts-20060613"
zend_extension="/usr/local/IonCube/ioncube_loader_lin_5.2.so"

Worked like a charm.

frozenrey’s picture

This saved my day- (the site was hosted @ GreenGeeks as well)- thank you. but wonder why this happened.

ravi1205’s picture

Dear Friend,

am too having same problem in my shared hosting and tried lot but still no solution found. Please explain this how to do this step by stem or give me any websites links to check this.

Thanks,
Ravi G

sjugge’s picture

May I suggest you contact your host for this, if any the above hasn't solved your issue I'm afraid I'll have quite a hard time pinpointing the exact cause of your issue especially since I'm only going by what I have found on these forums which solved the issue with my hosting company's setup.

In my experience it may not be a bad idea to attempt installing a completely fresh drupal instance on a subdomain, either with the version you are attempting to run or with the latest stable release.

You may also want to have a thorough read of http://drupal.org/getting-started/clean-urls

jmaines’s picture

My Drupal 7 site went down this evening showing the above error. I found that the hosting site rebuilt PHP and moved us to PHP 5.3 (from 5.2).

So run phpinfo.php and see if you are on PHP 5.3 and check the build date to see if it has recently changed.

We moved back to PHP 5.2 and is working now.

Fireiceearth’s picture

You can also move to php 5.4 in php configuration in cpanel