I'm trying to connect to a Microsoft SQL Server / Microsoft Azure database with PHP's PDO:
<?php
// no actual login data, but similar string lengths
$dbHost = 'aa1234bbb5.database.windows.net';
$dbUser = 'db_a1a1a1a1_b2b2_c3c3_d4d4_e5e5e5e5e5e5_ExternalWriter';
$dbPass = 'pPAs0wOoO1&r#dd';
$dbName = 'db_a1a1a1a1_b2b2_c3c3_d4d4_e5e5e5e5e5e5';
try {
$pdo = new PDO("dblib:host=$dbHost:1433;dbname=$dbName", $dbUser, $dbPass);
} catch (PDOException $e) {
echo "Failed to get DB handle: " . $e->getMessage() . "\n";
exit;
}
The PDO initialization throws an PDOException with the following message:
SQLSTATE[HY000] Name too long for LOGINREC field (severity 2)
I'm running PHP 5.4.41-0+deb7u1 on Debian 7.7 x64.
My questions boil down to:
- Why do I get this error message?
- How should I actually connect to the database?
Note: I cannot change the login data because I need to access the backend database of a Microsoft Access Web App. If you create such a Web App, Microsoft creates the database on one of its "publicly available" Azure servers. You can ask the server to give you a username and a password - but unfortunately you have to use whatever is given to you.

