How to use PHP dblib PDO driver with long usernames? / SQLSTATE [HY000] Name too long for LOGINREC field (severity 2)

I am trying to connect to Microsoft SQL Server / Microsoft Azure Database with PHP 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;
}

      

PDO initialization throws a PDOException with the following message:

SQLSTATE[HY000] Name too long for LOGINREC field (severity 2)

      

I am running PHP 5.4.41-0 + deb7u1 on Debian 7.7 x64.

My questions boil down to:

  • Why do I need this error message?
  • How do I actually connect to the database?

Note. I cannot change my login details because I need to access the backend database of a Microsoft Access web application. If you create such a web application, Microsoft will create a database on one of its "public" Azure servers. You can ask the server for a username and password, but unfortunately you have to use whatever is given to you.

+3


source to share


2 answers


The LOGINREC structure can be up to 30 characters long. You will have to shorten long lines.



+2


source


Have you tried SqlSrv - an alternative driver for MS SQL from Microsoft. From my understanding, PDO_DBLIB is an extension: http://php.net/manual/en/ref.pdo-dblib.php is no longer available on Windows with PHP 5.3 or newer. He recommended using SqlSrv and I checked your long dbUser and dbPass, it works fine on my side using SqlSrv: enter image description here

Please feel free to let me know if I misunderstood your problem.

Edit:



I tried to use odbc_connect on my side too and it works fine enter image description here

More information about the Microsoft SQL Server ODBC Driver for Linux can be found at http://www.codesynthesis.com/~boris/blog/2011/12/02/microsoft-sql-server-odbc-driver-linux/ and http: / /www.easysoft.com/developer/languages/php/sql_server_unix_tutorial.html#driver and it's not that hard to install it on 64 bit Debian or Ubuntu.

-1


source







All Articles