Arife Ljutviovska
Arife Ljutviovska

Reputation: 23

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?

Upvotes: 1

Views: 727

Answers (1)

Kuan Yung Liew
Kuan Yung Liew

Reputation: 61

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.

Upvotes: 1

Related Questions