This question already has answers here:
PDOException “could not find driver”
(42 answers)
php - PDOException could not find driver [duplicate]
(2 answers)
Laravel 5 PDOException Could Not Find Driver [duplicate]
(11 answers)
Laravel: PDOException: could not find driver
(32 answers)
Fatal error: Uncaught PDOException: could not find driver - windows MAMP php. The PHP.ini file has the correct part uncommented
(1 answer)
Closed 29 days ago.
I’ve been struggling trying to connect PHP to MySQL using the PDO() constructor since yesterday, and despite all the answers I’ve found on this problem, none of them worked.
In phpMyAdmin I have a database called ‘database_test’ and I’m trying to connect to it.
I’ve tried with ‘localhost’ and with ‘localhost:3306’:
<?php $mysqlConnection = new PDO('mysql:host=localhost;dbname=database_test;charset=utf8','root','root');?>
Both returning the same error when accessing http://localhost:8080/home.php :
Fatal error: Uncaught PDOException: could not find driver in
C:\Users...\home.php:3 Stack trace: #0 C:\Users...\home.php(3):
PDO->__construct('mysql:host=loca...', 'root', 'root') #1 {main}
thrown in C:\Users...\home.php on line 3
Yet, the module pdo_mysql is enabled
Mamp says : “To connect to the MySQL server from your own scripts use the following connection parameters”:
Host : localhost
Port : 3306
User : root
Password : root
Which I did.
Configuration
System : Windows 11
MAMP 4.2.0
Apache 2.2.31
MySQL 5.7.24
PHP 7.4.1
PhpMyAdmin 4.8.3
In phpinfo():
mysqlnd
enabled
API extensions
mysqli,pdo_mysql
PDO support
enabled
PDO drivers
sqlite, mysql
PDO Driver for MySQL
enabled
Client API version
mysqlnd 7.4.1
Pdo_sqlite
enabled
SQLite Library
3.30.1
In my php.ini (located here : C:\MAMP\conf\php7.4.1\php.ini), among the extensions that are uncommented I have :
extension=php_mysqli.dll
extension=php_pdo_sqlite.dll
extension=php_sqlite3.dll
extension=php_pdo_mysql.dll
; ...
; Directory in which the loadable extensions (modules) reside.
extension_dir = "C:\MAMP\bin\php\php7.4.1\ext\"
; ps : I've checked, they're all here
Related
Trying to connect to oracle 19c from php the server is not on the same machine as the php, I have so far installed instant client 19_15, added it as a environment variable, and then in the php.ini file I have taken off the semi colon for both the files extension=oci8_19 and extension=pdo_oci not sure what else to do to make the php to connect to the oracle db.
some error messages I have been getting are: PDO: connection failed: could not find driver
and from oci_connect: Fatal error: Uncaught Error: Call to undefined function oci_connect() in Stack trace: #0 {main} thrown in on line 7
p.s. architecture is x64, php version is 8.1.8 and using apache24 lounge
I'm running PHP 7.1 on an IIS 10.0 server and trying to connect to a MSSQL database.
Trying to instantiate a connection like this:
$dbh = new PDO("sqlsrv:Server=#server#;Database=#dbname#", "#username#", "#passwd#");
Gives me this error:
Fatal error: Uncaught PDOException: could not find driver in C:\inetpub\wwwroot\projects\test.php:6 Stack trace: #0 C:\inetpub\wwwroot\projects\test.php(6): PDO->__construct('sqlsrv:Server=...', '#username', '#pwd...') #1 {main} thrown in C:\inetpub\wwwroot\projects\test.php on line 6
However, sqlsrv is activated in my php.ini:
extension=php_sqlsrv.dll
extension=php_pdo_sqlsrv.dll
It's uncommented, and it's the right php.ini (already checked with phpinfo()). Restarting the server also didn't do anything.
I really don't understand why this is happening when the driver is obviously installed :/
What makes it extra weird is that I have another application running on the same server that also connects to a MSSQL database and it works with no problems, it had an automatic installer though so I didn't have to configure anything myself. It also connects to a local db and right now I'm trying to connect to a remote one if that makes a difference.
I am trying to connect to an existing database I created via DB browser for SQLite. It is saved as a file on my computer.
When using getAvailableDrivers, I am getting both MySQL and SQLite.
In phpinfo() I have the following entries:
PDO
PDO drivers -> MySQL, SQLite
pdo_sqlite
SQLite library -> 3.8.10.2
SQLite3
SQLite3 module version -> 0.7-dev
SQLite Library 3.9.10.2
SQLite3 extension dir -> c:\xampp\SQLite
I have written the following code to just establish connection:
<?php
phpinfo();
print_r(PDO::getAvailableDrivers());
$handler = new PDO('SQLite3:host=127.0.0.1;dbname=test', '', '');
?>
But when I try it I get the following error message:
Fatal error: Uncaught exception 'PDOException' with message 'could not find driver' in C:\xampp\htdocs\Ebsco\Users.php:4 Stack trace: #0 C:\xampp\htdocs\Ebsco\Users.php(4): PDO->__construct('SQLite3:host=12...', '', '') #1 {main} thrown in C:\xampp\htdocs\Ebsco\Users.php on line 4
I have searched several places online and several answers on Stack Overflow, but they did not help with a solution.
Any idea what could be causing this?
I noticed that the dir in the error message is not the same directory which I specified in the php.ini (which is also returned by phpinfo();), but I'm not sure if that is the cause, and if so what is causing it to search for the driver in that location.
I'm updating a application to stop using 'mssql_connect' to use PDO with ODBC for PHP 7.
Locally, I'm using XAMPP on Windows 8 and my application works fine. However, when I upload it to the Ubuntu server (Locaweb hosting, in Brazil) it returns the following error:
PDOException: SQLSTATE[IM002] SQLDriverConnect: 0 [unixODBC][Driver Manager]Data source name not found, and no default driver specified in /public_html/user/log-connections/connection.php:28 Stack trace: #0 /public_html/user/log-connections/connection.php(28): PDO->__construct('odbc:Driver={SQ...') #1 /public_html/user/log-connections/login.php(2): require_once('/public_html/user...') #2 {main}
The line causing the error (connection.php:28) is this one:
$pdo = new PDO("odbc:Driver={SQL Server}; Server={$servername}; Database={$dbname};", $username, $password);
I already tried using other driver names, such as "SQL Server Native Client", "FreeTDS", etc. But all returns the same error. Another thing is that the SQL Server isn't on the same server.
The solutions that I found on my research was telling me change the odbc.ini file and other files. But, I don't have access to those file on the server. Besides, on my local, I didn't change none of those files, just extended the modules to activate PDO and ODBC on the PHP.
Also, I already checked the phpInfo and the PDO and ODBC are enabled with "PDO Driver for ODBC (unixODBC)".
Anyone have experienced this kind of problem?
This question already has answers here:
phpmyadmin issuing a fatal error for PMA_DBI_num_rows()
(2 answers)
Closed 9 years ago.
I have installed phpmyadmin but when I try to launch it won't. I have this error :
Fatal error: Call to undefined function PMA_DBI_num_rows() in /usr/share/phpmyadmin/libraries/navigation/Nodes/Node.class.php on line 397
I have installed php5-mysql but it still not working. Which module that contains PMA_DBI_num_rows() function?
Thanks in advance
The PMA_DBI_num_rows() function is implemented in one of the dbi libraries, which are located under phpmyadmin/libraries/dbi
They should be part of any phpMyAdmin installation, so I'm wondering if you have an incomplete or damaged installation.
phpMyAdmin will load one of its dbi drivers depending on the value of the extension, in your config file:
$cfg['Servers'][$i]['extension'] = 'mysqli';
Here's where it loads the dbi, from code in libraries/database_interface.lib.php:
include_once './libraries/dbi/'
. $GLOBALS['cfg']['Server']['extension'] . '.dbi.lib.php';
So either you have misconfigured your config file with an unknown value for extension, or else you are missing the file corresponding to a valid extension.
The valid values for extension are 'mysql', 'mysqli', and 'drizzle'.
Just install the following:
apt-get install php5-mysql