How do you connect with your Azure database using PDO with PHP version 5.5?

Bruce Gust
Bruce Gust used Ask the Experts™
My company recently moved to an Azure server and with that came a more secure database dynamic. Alas, my PDO connection is now not working and I'm stuck.

Let me preface this by saying I'm running PHP 5.5.30 and updating is not an option just because of the antiquated code that characterizes the app. I'm concerned that an update would knock some things over and it would be a real mess.

The PDO that I'm working was built with a view to a more contemporary and secure future. Until everything is in place, however, we're taking baby steps and that brings us to the current dilemma.

Here's what I've got currently:


$database = "accurate";

try {
	 $options = array(
	PDO::MYSQL_ATTR_SSL_CERT  => accurate',
    $conn = new PDO($test, $user, $password);
} catch (PDOException $e) {
    echo 'Connection failed: ' . $e->getMessage();


Open in new window

Where you see "accurate," I'm referring to what I know to be an accurate setting, be it a database name or the location of the SSL_CERT. When I run this, I get:

Warning: PDO::__construct(): Unable to set private key file `D:\www\toolbox' in D:\www\toolbox\functions\personnel.php on line 23

Warning: PDO::__construct(): failed to create an SSL handle in D:\www\toolbox\functions\personnel.php on line 23

Warning: PDO::__construct(): Cannot connect to MySQL by using SSL in D:\www\toolbox\functions\personnel.php on line 23

Warning: PDO::__construct(): [2002] (trying to connect via tcp:// in D:\www\toolbox\functions\personnel.php on line 23
Connection failed: SQLSTATE[HY000] [2002]

I was provided the "PDO::MYSQL_ATTR_SSL_VERIFY_SERVER_CERT" dynamic as a suggestion that would convince the system to circumvent the process where the server is being validated, but when I try that, I get:

Fatal error: Undefined class constant 'MYSQL_ATTR_SSL_VERIFY_SERVER_CERT' in D:\www\toolbox\functions\personnel.php on line 21

...which I believe is a result of my version of PHP being less than what's needed for that constant to resonate as legitimate.


Any suggestions?
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
2015 Top Expert (Most Article Points)
Azure have retired 5.5 and require 5.6 as a minimum. Have you configured Azure to use a custom PHP runtime version?
Bruce GustPHP Developer


That's what I needed to know!

Thanks, Chris!

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial