CakePHP Class 'PDO' not found - php

I have shifted my CakePHP (2.3.1 stable version) site to Host-ed.me and I am getting PDO class not found error. How to enble PDO on Host-ed.me server. Any suggestion is highly appreciated.

I suggest to first compare your previous/local PHP configuration with the configuration on hosted.me.
You can do so by generating a phpinfo() report of both. be sure to remove the phpinfo page afterwards - having a publicly visible phpinfo page on your website is a major security risk.
Check if PDO is really not installed on the webserver, either via the phpinfo() report or via instructions found in this question; How to determine if PDO is enabled in PHP?
You may also check if hosted.me is not using an outdated version of php, otherwise you may run into other problems later on
If PDO is not installed and is required for your website (or the php version is too old), there's no other option than to contact the hosting provider and ask them if it is possible to have it installed or your website be hosted on a different server.
Finally, if these options do not give you a solution, find a better hosting provider that does have a decent PHP installation :)

Check out this blog for details.
Basically, you have to do the folllowing:
1. Check if PDO is installed (lookinto your phpinfo() output / write simple program)
2. Install PDO, using yum install php-pdo
Test again, using the above scripts and you should be good to go.

You just need to enable the PHP extensions:
pdo
pdo_sqlite
sqlite
or ask host to enable them

Related

PHP postgres enable ssl support

Sorry to get back to you for a question that has been asked many years ago. But I am really stuck with this.
I have a legacy application which is very old, running PHP 5.2.17.
I followed this guide to setup my docker container
https://andrewscaya.net/blog/bringing-php-52-back-life
I have everything setup correctly. I made a downloaded and compiled a PHP installation and configured this with Apache. And its working fine with php.
However, it is essential that I have SSL support (in PHP) for the POSTGRES connection.
Which is now default not enabled according to PHPINFO
I have basically the very same problem somebody else had many years ago. SSL support of Pgsql
See:
Enable SSL support for pgsql
So from what I am understanding is that I need to recompile PHP again, but with a package called libpg ?
Where do I get this package and how can I compile this with the PHP source code?
After 2 days of searching I finally found LAPP stack which has some older versions available with pgsql ssl support
https://community.bitnami.com/t/can-i-get-the-installers-for-wapp-and-lapp-stacks-for-5-4-45/38548
In the long-run I would recommend upgrading PHP versions, but I understand that this can be a lot of work. There are many good guides on upgrading versions. I recommend going through the version upgrades one-by-one, dealing with deprecated features and other potential problems one-at-a-time and testing each script.
In the short-term, I'm not sure if this would work, but PDO is supported in 5.2 (actually in 5.1 even) and as it simply passes info to the PostgreSQL library, I would expect SSL support to work. I have used it in 5.4, and I am not aware of any changes made between those two versions.
There is a solution here, by IMSoP, that explains how to get this working and points you to more official documentation if you need more info: Connecting to PGSQL over SSL via PHP PDO
If this fails, a second approach that I would try would be to create an SSH tunnel to connect to a local port. An example would be:
ssh -L 127.0.0.1:5443:127.0.0.1:5432 username#remoteboxaddress
Then you can initiate what looks to PHP like a local connection on port 5433, but it will actually be a (secure) SSH tunnel to the remote box. This will also require that the remote box is configured to accept (non-encrypted) local connections, and that you have SSH access to it. Then, if you test it out and it works, you can make a script to start the tunnel on boot, or better yet, when the webserver is started; this necessitates using an authentication method like keys stored in a file, that doesn't require the entering of a password. So...there are a lot of "if's" here, in terms of whether or not you will be able to get this solution to work, but it can be done if you have root access on both servers, and occasionally if you do not, depending on how they are configured.
Hopefully, one of these two solutions will work for you.

How to enable mysqli with PHP 7?

I have the latest version of Apache (Apache 2.4), latest version of PHP (PHP7), and latest version of MySQL (not sure the version but I have WorkBench version 6.3). In the past, when I checked if my PHP was working by this line of code <?php phpinfo(); ?> it would show that I have MySQL / mysqli installed and ready to go. But with PHP7 it shows mysqlnd.
I try using mysqli commands to check if I can connect to my database by mysqli_ping() and I also tried connecting to the database using server, user, pass. I keep getting errors such as Class mysqli not found. Or Call to undefined function mysqli_ping(). I've tried searching the net for some answers and All I could find was that I need to install MySQL (but a few sites said it was deprecated).
Am I able to get mysqli for PHP7? Or do I use mysqlnd? What is mysqlnd? Is it a new version of MySQL/mysqli?
Update 2020
For Windows 10 users I strongly recommend windows subsystem for linux (WSL 2) and setup your server there.
If you need php and mysql access in windows environment, then the fastest way is to install Wampserver. If you also need access to php through console then add php location (like C:\wamp64\bin\php\php7.4.11) to environment variables.
If that doesn't suit you and you need full setup always enabled on your system then follow install with choco.
To work properly with apache and load all needed extensions (including php_mysqli) you need ThreadSafe version of PHP, so make sure to download correct version or if you use Chocolatey to manage your windows applications, then just install php with this command:
choco install php --package-parameters='"/ThreadSafe "'.
This will install php in C:\tools\php72 directory, but you can overwrite it with another parameter:
choco install php --package-parameters='"/ThreadSafe ""/InstallDir:C:\PHP"""'.
The mysqlnd extension is part of PHP. It was developed as an alternative to bundling the libmysqlclient, because that library had license conditions that made it awkward to bundle with PHP.
You won't use mysqlnd directly. It's an internal library that is used by mysqli and pdo_mysql as a means to communicate with the MySQL Server.
As for mysqli, yes, it's available for PHP 7. I don't use Windows, but apparently not all extensions are enabled by default.
You probably need to edit your php.ini and uncomment the line
extension=ext_mysqli.dll
or whatever it is for that extension. It might already be in the file, but commented out. So go take a look and see.
Check if your system path environmental variable includes the PHP installation directory. That worked for me on with PHP 7.1 / Apache 2.4 / Windows Server 2016.

Installing MySQLi shows it will disable MySQL will it affect my current code?

I am trying to install mysqli extension on my server(CENTOS) using WHM Easy Apache 3.
I am selecting mysqli from Exhaustive Options List.
When I select mysqli extension it shows message that this action will disable current mysql extension.
Now, my problem is whether this action will affect my current websites code which is already using mysql extension. I have multiple websites on this server all are built using mysql extension.
I need mysqli for my new website of opencart.
Please help me to understand this warning also let me know if mysql is disabled then can I enable it again and how? so that I can use both mysql & mysqli extensions and my old work will not be affected by this change.
Actually I was in a bit of a hurry, so I took risk to build apache and php using easyapache3 and guess what.... my current code with mysql is not affected at all and both mysql and mysqli extensions are working fine, though I will not recommend to use mysql further to any one, but now I have a time to upgrade my old sites to mysqli and also I am able to use mysqli immediately for my new projects.
Note : when you build apache and php your php.ini might be rewritten by new default settings, so if you have any custom settings in php.ini remember to backup it first and then build apache.
Thanks a lot...

can't enable PDO in localhost apache php vesion 5.2.6

I can't enable PDO in my localhost.
I have read the php installation manual and attempted to do the same thing, but it isn't working.
When i open phpinfo and search for pdo it appear that pdo_mysql is not enabled, as shown in the below image.
I uncommented all pdo extension in php.ini and that didn't help.
I also searched for the pdo.dll in my extension and found it.
Any ideas what is wrong?
From the image of your phpinfo it's only showing sqllite and mysql is missing.
In PHP 5.2 I believe PDO is not available under default compile so you'll need to make sure it's actually compiled into PHP by adding --with-pdo-mysql into your compile script or if available via your webhosting panel somewhere. Personally I'd recommend having your PHP version updated to a secure version but as always you have to make sure any existing code is compatible.

WHM enable PHP PDO library

I just switched hosts from a shared to a vps host and I am configuring my WHM account. I want to be able to use the PHP PDO library. I know how to get to the apache update form and locate the pdo section. The only problem is that there are two options, a pdo check box that reads
Includes SQLite support. MySQL support is available. If you plan on installing or updating >PDO drivers (freetds, oracle, etc) via PECL you might want to skip this option as PECL will >install the version of PDO it has. This option will make the following changes to your >profile prior to the build:
Enables:
SQLite3
and a PDO_MYSQL box that reads
This option will make the following changes to your profile prior to the build:
Enables:
PDO
I do not know which option to choose.
The second one, the first is to enable SQLite; I'm guessing you wanna use MySQL ?

Categories