logo
Apache Lounge
Webmasters

 

About Forum Index Downloads Search Register Log in RSS X


Keep Server Online

If you find the Apache Lounge, the downloads and overall help useful, please express your satisfaction with a donation.

or

Bitcoin

A donation makes a contribution towards the costs, the time and effort that's going in this site and building.

Thank You! Steffen

Your donations will help to keep this site alive and well, and continuing building binaries. Apache Lounge is not sponsored.
Post new topic   Forum Index -> Other Software View previous topic :: View next topic
Reply to topic   Topic: PHP - PDO could not find driver
Author
Mike1965SA



Joined: 26 Oct 2021
Posts: 5
Location: Australia, Adelaide

PostPosted: Thu 28 Oct '21 14:08    Post subject: PHP - PDO could not find driver Reply with quote

Hello all,
I am undertaking a tutorial on PHP MySQL and PDO. I have followed, I believe, all the instructions to use PDO in apache. I have Apache 2.4.37, PHP 7.4.23 and MySQL 5.7.24, running on my Win10 pc.

I have a simple script to check whether PDO is available or not, and it has an error message saying '
Quote:
could not find driver
'.
The PHP error log from wamp says,

Quote:
[28-Oct-2021 11:55:02 UTC] PHP Warning: PHP Startup: Failed to load D:/wamp64/bin/php/php7.4.23/ext/php_ffi, The system cannot find the file specified.
in Unknown on line 0
[28-Oct-2021 11:55:03 UTC] PHP Warning: PHP Startup: Unable to load dynamic library 'php_intl' (tried: D:/wamp64/bin/php/php7.4.23/ext/php_intl (The specified module could not be found.), D:/wamp64/bin/php/php7.4.23/ext/php_php_intl.dll (The specified module could not be found.)) in Unknown on line 0
[28-Oct-2021 11:55:03 UTC] PHP Warning: PHP Startup: Failed to load D:/wamp64/bin/php/php7.4.23/ext/php_imap, The system cannot find the file specified.
in Unknown on line 0
[28-Oct-2021 11:55:04 UTC] PHP Warning: PHP Startup: Unable to load dynamic library 'pdo_sqlite' (tried: D:/wamp64/bin/php/php7.4.23/ext/pdo_sqlite (The specified module could not be found.), D:/wamp64/bin/php/php7.4.23/ext/php_pdo_sqlite.dll (The specified module could not be found.)) in Unknown on line 0
[28-Oct-2021 11:55:04 UTC] PHP Warning: PHP Startup: Failed to load D:/wamp64/bin/php/php7.4.23/ext/php_ffi, The system cannot find the file specified.
in Unknown on line 0
[28-Oct-2021 11:55:04 UTC] PHP Warning: PHP Startup: Unable to load dynamic library 'php_intl' (tried: D:/wamp64/bin/php/php7.4.23/ext/php_intl (The specified module could not be found.), D:/wamp64/bin/php/php7.4.23/ext/php_php_intl.dll (The specified module could not be found.)) in Unknown on line 0
[28-Oct-2021 11:55:04 UTC] PHP Warning: PHP Startup: Failed to load D:/wamp64/bin/php/php7.4.23/ext/php_imap, The system cannot find the file specified.
in Unknown on line 0
[28-Oct-2021 11:55:04 UTC] PHP Warning: PHP Startup: Unable to load dynamic library 'pdo_sqlite' (tried: D:/wamp64/bin/php/php7.4.23/ext/pdo_sqlite (The specified module could not be found.), D:/wamp64/bin/php/php7.4.23/ext/php_pdo_sqlite.dll (The specified module could not be found.)) in Unknown on line 0



The PHP.ini file shows
Quote:
extension=bz2
extension=curl
;extension=dba
extension=com_dotnet
;extension=enchant
extension=php_ffi
extension=fileinfo
;extension=ftp
extension=gd2
extension=gettext
extension=gmp
extension=php_intl
extension=php_imap
;extension=interbase
extension=ldap

extension=mbstring
extension=exif ; Must be after mbstring as it depends on it
extension=mysqli
;extension=odbc
extension=openssl
;extension=pdo_firebird
extension=pdo_mysql
;extension=pdo_oci
;extension=oci8_12c ; Use with Oracle Database 12c Instant Client
;extension=pdo_odbc
;extension=pdo_pgsql
extension=pdo_sqlite
;extension=pgsql
;extension=phpdbg_webhelper
;extension=shmop

; The MIBS data available in the PHP distribution must be installed.
; See http://www.php.net/manual/en/snmp.installation.php
;extension=snmp

extension=soap
extension=sockets
;extension=sodium

;extension=sqlite3
;extension=sysvshm
;extension=tidy
;extension=xmlrpc
extension=xsl
;extension=zend_test


When I run php.exe -m on the command line I get
Quote:
Warning: PHP Startup: Unable to load dynamic library 'intl' (tried: D:/wamp64/bin/php/php7.4.23/ext/intl (The specified module could not be found.), D:/wamp64/bin/php/php7.4.23/ext/php_intl.dll (The specified module could not be found.)) in Unknown on line 0

Warning: PHP Startup: Unable to load dynamic library 'pdo_sqlite' (tried: D:/wamp64/bin/php/php7.4.23/ext/pdo_sqlite (The specified module could not be found.), D:/wamp64/bin/php/php7.4.23/ext/php_pdo_sqlite.dll (The specified module could not be found.)) in Unknown on line 0

along with numerous extensions including

Quote:
PDO
pdo_mysql
PDO_ODBC
pdo_pgsql


In wamp when I see the php extensions loaded they pdo_mysql is there with a green tick.

I have read through posts on this platform, as well as the PHP manual, stackoverflow, phphelp.com and other posts using internet search. All seem to show that I should have the pdo drivers loaded. I am not sure where else to turn for a solution.
I have tried different versions of PHP, all with the same result. I reinstalled PHP as well to no avail.

Does anyone have a suggestion that might work??

Many thanks


Mike
Back to top
Otomatic



Joined: 01 Sep 2011
Posts: 212
Location: Paris, France, EU

PostPosted: Thu 28 Oct '21 16:14    Post subject: Reply with quote

Hi,

Apache 2.4.37 is Wampserver 3.1.7 released over two years ago with PHP 7.3.1 at the most.

If you want to use more recent PHP versions like PHP 7.4.23, you also need to upgrade Wampserver to support the latest versions of PHP and Apache.
We are at Wampserver 3.2.5 and Apache 2.4.51.

Upgrade Wampserver to 3.2.5 and use Apache 2.4.51.
Everything is on https://wampserver.aviatechno.net

Your problem is only a problem of non updates. PHP 7.4 support dates from Wampserver 3.2.0

It looks like you did not install PHP 7.4.23 from the addon since it requires Wampserver 3.2.5 to be installed.
Back to top
Mike1965SA



Joined: 26 Oct 2021
Posts: 5
Location: Australia, Adelaide

PostPosted: Sat 30 Oct '21 2:49    Post subject: Reply with quote

thanks
Back to top
Mike1965SA



Joined: 26 Oct 2021
Posts: 5
Location: Australia, Adelaide

PostPosted: Sat 30 Oct '21 3:55    Post subject: Reply with quote

upgraded/updated all those things to the numbers you suggested, and
the error remains. Is there something else??
Back to top
Otomatic



Joined: 01 Sep 2011
Posts: 212
Location: Paris, France, EU

PostPosted: Sat 30 Oct '21 15:16    Post subject: Reply with quote

Hi,

There is no problem with Apache 2.4.51 and PHP 7.4.25.
All checked extensions are seen loaded by get_loaded_extensions() and there is no error in php_error.log.

And in CLI mode (Right-Click -> Tools -> Command Windows -> Command windows PHP) the command php -m is:
Code:

Microsoft Windows [version 10.0.19043.1320]
(c) Microsoft Corporation. Tous droits réservés.

E:\wamp64\bin\php\php7.4.25>php -m
[PHP Modules]
bcmath
bz2
calendar
Core
ctype
curl
date
dom
exif
fileinfo
filter
gd
gettext
gmp
hash
iconv
imap
intl
json
ldap
libxml
mbstring
mysqli
mysqlnd
openssl
pcre
PDO
pdo_mysql
pdo_sqlite
Phar
readline
Reflection
session
SimpleXML
soap
sockets
SPL
standard
tokenizer
xml
xmlreader
xmlrpc
xmlwriter
xsl
zip
zlib

[Zend Modules]

E:\wamp64\bin\php\php7.4.25>

We don't see FFI extensions, ZENDopcache and xdebug. Why ?
Because the first case is for PHP Web, i.e. from:
Code:
LoadModule php7_module "${INSTALL_DIR}/bin/php/php7.4.25/php7apache2_4.dll"
du fichier httpd.conf and therefore depends on the "php.ini" file located in:
PHPIniDir "${APACHE_DIR}/bin"
and this "file" is (dir php.ini):
Code:
E:\wamp64\bin\apache\apache2.4.51\bin>dir php.ini
30/10/2021  14:32 <SYMLINK>      php.ini [E:/wamp64/bin/php/php7.4.25/phpForApache.ini]

We can see that this "php.ini" is not a real file but a symbolic link to the real phpForApache.ini file of the PHP version used.
On the other hand, when we use the CLI mode and the php -m command, it will be the php.ini file that will be used and not phpForApache.ini.
So, if you want extensions in CLI mode, you have to validate them directly in the php.ini file and not through the Wampmanager menus.
Back to top
Mike1965SA



Joined: 26 Oct 2021
Posts: 5
Location: Australia, Adelaide

PostPosted: Sun 31 Oct '21 9:16    Post subject: Reply with quote

So what do I attempt to be able to use PHP-PDO??
Back to top
Mike1965SA



Joined: 26 Oct 2021
Posts: 5
Location: Australia, Adelaide

PostPosted: Sun 31 Oct '21 10:37    Post subject: Reply with quote

I found the error.
I was using mysqli:host= instead of mysql:host=

Quote:
try {
$conn = new PDO("mysqli:host=$serverName;dbname=myDataBase", $userName, $password);


//set PDO error mode to exception
$conn ->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
echo "PDO Connected successfully";
echo"<br/><br/>";
}
catch (PDOException $e) {
echo "Connection failed: " . $e->getMessage()." , PDO not available";
}


Not really sure why that made a difference but it did.

Many Thanks
Back to top


Reply to topic   Topic: PHP - PDO could not find driver View previous topic :: View next topic
Post new topic   Forum Index -> Other Software