0

I try to connect to my azure database only with the provided connection string. However I just get this error message:

Error connecting to SQL Server.PDOException Object ( [message:protected] => could not find driver [string:Exception:private] => [code:protected] => 0 [file:protected] => C:\XAMPP\htdocs\folder\Databaseconnection.php [line:protected] => 4 [trace:Exception:private] => Array ( [0] => Array ( [file] => C:\XAMPP\htdocs\folder\Databaseconnection.php [line] => 4 [function] => __construct [class] => PDO [type] => -> [args] => Array ( [0] => sqlsrv:server = tcp:{server}.database.windows.net,1433; Database = testdb [1] => {username} [2] => {password} ) ) ) [previous:Exception:private] => [errorInfo] => ) 1

The servername username and password is obviously changed here. I also allowed my own IP adress on the server firewall settings. Any help appriciated.

0

1 Answer 1

1

The reason is caused by that you want to use PHP PDO to connect Azure SQL Database, but the error information shows there is not a PHP driver to support SQL Azure connection.

You could reference this blog:Error connecting to SQL Server.PDOException Object (Azure).

You need to refer to the section PHP Version Support of the offical document Microsoft PHP Drivers for SQL Server Support Matrix to know what version of PHP PDO driver for Azure SQL Database is for PHP v7.4:

enter image description here

Please choose the suitable PHP version and SQL Server driver.

You could Download the Microsoft Drivers for PHP for SQL Server for your system. Also reference Production Release for the PHP drivers Version 5.6.0 for SQL Server.

Hope this helps.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.