Board index   FAQ   Search  
Register  Login
Board index php forum :: Database Other Database Engines

freeTDS / MSSQL issues

Do you have questions regarding other database enginges (not MySQL) -- ask here!

Moderators: macek, egami, gesf

freeTDS / MSSQL issues

Postby bmdumr » Mon Jul 18, 2011 9:05 pm

I'm having issues connecting to a MSSQL database that I need to make a connection to using PHP on Linux. I have freeTDS installed and I believe configured correctly via the freetds.conf file. PHP 5.3.6 has been compiled with the MSSQL extensions, and verified with phpinfo(). A simple script to test my connection using the mssql_connect() function fails with the basic output of "Unable to connect to server". The freeTDS log shows the following after failing to connect...

21:56:35.037917 2029 (log.c:190):Starting log file for FreeTDS 0.82
on 2011-07-18 21:56:35 with debug flags 0xffff.
21:56:35.038110 2029 (iconv.c:197):names for ISO-8859-1: ISO-8859-1
21:56:35.038123 2029 (iconv.c:197):names for UTF-8: UTF-8
21:56:35.038134 2029 (iconv.c:197):names for UCS-2LE: UCS-2LE
21:56:35.038143 2029 (iconv.c:197):names for UCS-2BE: UCS-2BE
21:56:35.038155 2029 (iconv.c:363):iconv to convert client-side data to the "ISO-8859-1" character set
21:56:35.038180 2029 (iconv.c:516):tds_iconv_info_init: converting "ISO-8859-1"->"UCS-2LE"
21:56:35.038195 2029 (net.c:210):Connecting to xxx.xxx.xxx.xxx port 1433 (TDS version 4.2)
21:56:35.038262 2029 (net.c:264):tds_open_socket: connect(2) returned "Operation now in progress"
21:56:40.038209 2029 (util.c:334):tdserror(0xa838dc0, 0xa960bf0, 20008, 115)
21:56:40.038276 2029 (dblib.c:7782):dbperror(0xa9604f0, 20008, 115)
21:56:40.038293 2029 (dblib.c:7835):20008: "Unable to open socket"
21:56:40.038304 2029 (dblib.c:7856):"Unable to open socket", client returns 2 (INT_CANCEL)
21:56:40.038314 2029 (util.c:368):tdserror: client library returned TDS_INT_CANCEL(2)
21:56:40.038324 2029 (util.c:389):tdserror: returning TDS_INT_CANCEL(2)
21:56:40.038333 2029 (net.c:310):tds_open_socket() failed
21:56:40.038347 2029 (dblib.c:1372):dbclose(0xa9604f0)
21:56:40.038357 2029 (dblib.c:256):dblib_del_connection(0xb7074560, 0xa960bf0)
21:56:40.038376 2029 (mem.c:563):tds_free_all_results()
21:56:40.038392 2029 (dblib.c:303):dblib_release_tds_ctx(1)
21:56:40.038406 2029 (dblib.c:5727):dbfreebuf(0xa9604f0)
21:56:40.038526 2029 (dblib.c:718):dbloginfree(0xa7c1c90)
21:56:40.038860 2029 (dblib.c:1442):dbexit(void)
21:56:40.038878 2029 (dblib.c:303):dblib_release_tds_ctx(1)


The tsql command prompt that freeTDS refers to also results in a similar "Unable to open socket" error as shown above. I'm trying to understand if this is my outbound socket on my webserver or the inbound socket on the MSSQL server. I've verified the connection through Windows/ODBC, so I know the host, port, username, password, etc. are good. I've also tried various versions of TDS (4.2, 7.0, and 8.0) with no luck. The FreeTDS documentation is not the easiest to understand. The manual mentions other ODBC methods to connect, but I'm assuming the mssql_connect() function is the simplest. I'll go the ODBC route if I can't get this to work.

I just can't get Linux/PHP to play nice with MSSQL... probably to be expected, but I NEED THIS TO WORK.

Any help greatly appreciated.
bmdumr
New php-forum User
New php-forum User
 
Posts: 1
Joined: Mon Jul 18, 2011 8:45 pm

Re: freeTDS / MSSQL issues

Postby andystewart » Fri Apr 11, 2014 1:50 am

Hi, I have the same problem - did you find a solution?
andystewart
New php-forum User
New php-forum User
 
Posts: 2
Joined: Fri Apr 11, 2014 1:48 am

Re: freeTDS / MSSQL issues

Postby andystewart » Fri Apr 11, 2014 3:05 am

Solved for me after required port on local server was opened inbound and outbound
andystewart
New php-forum User
New php-forum User
 
Posts: 2
Joined: Fri Apr 11, 2014 1:48 am

Re: freeTDS / MSSQL issues

Postby seandisanti » Fri Apr 11, 2014 8:15 pm

Awesome, thanks for sharing your fix in case it can help anyone else
seandisanti
php-forum Fan User
php-forum Fan User
 
Posts: 838
Joined: Mon Oct 01, 2012 12:32 pm


Return to Other Database Engines

Who is online

Users browsing this forum: No registered users and 1 guest

Sponsored by Sitebuilder Web hosting and Traduzioni Italiano Rumeno and antispam for cPanel.