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.
Related
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.
I am currently running an Apache 2.4 server with PHP 5.5.1, and it is connected to Django via mod_wsgi (in case that matters). This is all running on Oracle Linux. In this set-up, I am trying to use mysqli and the method mysqli_connect. However, I am facing issues with my mysqli set-up. I have used the following website: MySQLi Setup. However, even after running ./configure --with-mysqli=/usr/bin/mysqlconfig and ./configure --with-mysqli, I still do not see a mysqli section in my phpinfo() test site. I have run make and make install after both and it has worked fine.
Furthermore, when I try the following command ./configure --with-mysql=/usr/bin/mysql_config --with-mysqli=mysqlnd, I get the following error: configure: error: Cannot find MySQL header files under /usr/bin/mysql_config. Note that the MySQL client library is not bundled anymore!
On top of this, I have uncommented the extension=php_mysqli.dll line.
Right now, I have an idea of what I need to do, which is to get ahold of the MySQL client library and allow access to it by php. However, I am unsure of how to do this, and many of the questions + answers I have found have not worked.
Any help is appreciated. Thanks.
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
I have installed Apache2.2 and then installed PHP5.4.8. I cannot get my new .php file to load in a browser because it keeps giving me the error Fatal error: Call to undefined function mysql_connect(). When I load the test.php file which has only this in it:
<?php phpinfo(); ?> it returns a page that shows information about PHP but where it would show the MySQL modules it only shows mysqlnd. What is that? Also, I have gone through the php.ini file and uncommented the proper lines for MySQL integration as well as having edited the Apache2.2 httpd file. Does anyone have any answers as to why MySQL isn't working? Thanks in advance.
Also, Ive tried many of the solutions from this website as well as many google searches. I can't seem to figure it out. :-(
1) Have a look on choosing MySQL API. It is recommended to use mysqli extension.
2) According to Other changes to extensions, the MySQL extensions mysql, mysqli and PDO_mysql use mysqlnd as the default library now.
A quote from MySQL Native Driver - mysqlnd site:
Although MySQL Native Driver is written as a PHP extension, it is important to note that it does not provide a new API to the PHP programmer. The programmer APIs for MySQL database connectivity are provided by the MySQL extension, mysqli and PDO MYSQL. These extensions can now use the services of MySQL Native Driver to communicate with the MySQL Server. Therefore, you should not think of MySQL Native Driver as an API.
That means, the mysqlnd extension does not export any function you can use in your scripts, but acts as a bridge between your code and one of mysql, mysqli, pdo_mysql extensions.
You mentioned, that phpinfo() shows only mysqlnd. The fact you don't see section titled MySQL there means that mysql extension is not enabled (commented out) in php.ini (Windows) or your php is not compiled with mysql support (Linux). More details about installing MySQL extension are here.
What is your OS?
To have a successfull MySQL connection you should:
Install the MySQL Server
Configure the PHP to use the proper mysql socket: (in php.ini search for mysql.default_socket - point it to the mysql server).
Reboot the web server - Apache
I have a php project developed using zend framework, when i hosted to my local server(CentOS) i got the
below error:
The mysql driver is not currently installed
I have installed and enabled pdo_mysql on php.ini, but it is not effected my phpinfo.
Phpinfo only show pdo_sqlite not see pdo_mysql.
Another issue in my machine is phpinfo shows PHP version 5.2.8 and from terminal it shows PHP 5.1.6. Are there two php version running my machine?
Help is highly appreciated.
Check your phpinfo() output for the location of the php.ini file used and make sure to adapt that file. It's perfectly possible to have multiple versions of php running on a single computer.
It will show near the top of the output as (here's mine):
Loaded Configuration File /etc/php5/apache2filter/php.ini
that would be the location of the file you need to edit to affect your webserver instance php behaviour.
make sure to extension=php_pdo_mysql.so in it to load the mysql pdo driver
finally also make sure that extension_dir points to the directory where your libraries are found, using an absolute path; you can find that in phpinfo() under Core (and in your php.ini when you want to adapt it obviously)