GavMJM Posted December 19, 2012 Share Posted December 19, 2012 (edited) Hi all, First off, please excuse my ignorance, I've not used PHP before today... I'm trying to connect to an a Microsoft Azure SQL Database (which is a hosted version of SQL 2008) using MSSQL_Connect and FreeTDS. I believe that because of the way Azure works, you *HAVE* to specify a database to connect to. I can run this successfully: tsql -S AZURE -D 'DatabaseName' -U 'username@database.database.windows.net' -P 'password' However, when I try and run this (in PHP), it does not work: <?php putenv('FREETDS=/etc/freetds.conf'); putenv('FREETDSCONF=/etc/freetds.conf'); if (!$connection = @mssql_connect( 'AZURE' , 'username@database.database.windows.net', 'password')) { print("Could not connect!"); } else { print("Connected!"); } ?> My '/usr/local/etc/freetds.conf' looks like this: [AZURE] host = database.database.windows.net port = 1433 tds version = 7.2 client charset = UTF-8 encryption = required TSQL -C outputs this: Compile-time settings (established with the "configure" script) Version: freetds v0.91 freetds.conf directory: /etc MS db-lib source compatibility: yes Sybase binary compatibility: yes Thread safety: yes iconv library: yes TDS version: 4.2 iODBC: no unixodbc: yes SSPI "trusted" logins: no Kerberos: yes When I run the PHP, I get this in the freetds dump file: net.c:1370:handshake succeeded!! gssapi.c:215:kerberos name MSSQLSvc/database.database.windows.net:1433 login.c:466:login packet rejected util.c:156:Changed query state from IDLE to DEAD util.c:331:tdserror(0xb25da0, 0xc75880, 20002, 0) dblib.c:7929:dbperror(0xc74d60, 20002, 0) dblib.c:7981:20002: "Adaptive Server connection failed" dblib.c:8002:"Adaptive Server connection failed", client returns 2 (INT_CANCEL) Any ideas? I've gone none, so any help would be massively appreciated. Many thanks, GavMJM Edited December 19, 2012 by GavMJM Quote Link to comment Share on other sites More sharing options...
JustLikeIcarus Posted January 11, 2013 Share Posted January 11, 2013 Per the following from MSDN try changing your username to username@database. See if that gets you anywhere For example, if your login was named login1 and the fully qualified name of your SQL Database server is servername.database.windows.net, the username parameter of your connection string should be: login1@servername. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.