简体   繁体   中英

PHP PDO - can't see available drivers

I am new to php pdo and I have to connect to MySQL driver but when I try to see which driver is available with

print_r(PDO::getAvailableDrivers())

returns empty array.What I have to do to see that MySQL driver is available?

I encountered a similar issue before, PDO return error message Could not find driver , but when I check, PDO is working fine, but has empty available drivers.

Later, I found out that the solution to my issue is, change the c:\php path in the system environment to c:\xampp\php . You might save your PHP or XAMPP in a different location, but you get the idea.

The thing is, before I use phpMyAdmin , I already installed a PHP on my computer, and set the system path to this PHP. But later I install XAMPP because I wanna use MySQL , but my system environment still runs PHP code through the old PHP path. After changing the path, the problem solved.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM