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

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:

<?php
$user="accurate";
$host="accurate";

$password='accurate';
$database = "accurate";
$test="mysql:host=$host;dbname=$database";

try {
	 $options = array(
	PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION,
	PDO::MYSQL_ATTR_INIT_COMMAND => "SET NAMES utf8",
	PDO::MYSQL_ATTR_SSL_KEY => NULL,
	PDO::MYSQL_ATTR_SSL_CERT  => accurate',
	PDO::MYSQL_ATTR_SSL_CA => NULL,
	//PDO::MYSQL_ATTR_SSL_VERIFY_SERVER_CERT => false
	);
    $conn = new PDO($test, $user, $password);
    $conn->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
} 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://east-prod-mysql01.mysql.database.azure.com:3306) 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.

So...

Any suggestions?
brucegustPHP DeveloperAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Chris Harte2015 Top Expert (Most Article Points)Commented:
Azure have retired 5.5 and require 5.6 as a minimum. Have you configured Azure to use a custom PHP runtime version?

https://docs.microsoft.com/en-us/azure/app-service/web-sites-php-configure
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
brucegustPHP DeveloperAuthor Commented:
That's what I needed to know!

Thanks, Chris!
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Databases

From novice to tech pro — start learning today.