Lee
Lee

Reputation: 144

How to connect to MySQL using PHP PDO in easyphp 16.1.1

I'm trying to move over to PHP7 and use the latest EasyPHP but I can't for the life of me figure out how to connect to MySQL using the PDO

I've set up a working directory: C:\Program Files (x86)\EasyPHP-Devserver-16.1\eds-www\TechMexv3 with cURL

I've installed all my database tables in phpMyAdmin which has worked fine

I'm now trying to connect with the following:

$DBH = new PDOEx('mysql:host=localhost; dbname=techsmex; charset=utf8mb4', 'root', '');

And I'm getting the error: could not find driver

Do I need to install a driver from somewhere that doesn't come with EasyPHP?

Upvotes: 2

Views: 6539

Answers (1)

Daniel Nora
Daniel Nora

Reputation: 61

In EasyPHP Devserver 16.1.1, the default configuration file for php (php.ini) has the PDO MySQL extension disabled by default.

You have to enable it and restart your server before you can connect to your database.

In order to do this,

  1. Go to your EasyPHP Devserver Dashboard;
  2. Stop your HTTP Server in case it is running;
  3. Select the version you are using for PHP in the left panel;
  4. Open the corresponding folder for your PHP.

In it, is your php.ini file. Open the file with your preferred text editor, and search for ;extension=php_pdo_mysql.dll

Simply remove the semicolon in the beginning so the extension gets activated upon restarting of the HTTP server. Go to your dashboard's main page, and restart the HTTP server.

Upvotes: 3

Related Questions