1. XAMPP 1.4.6
2. modify php.ini
----enxtension = php_mssql.dll
----extension = mysql.so
3. modify freetds.conf
[global]
tds version = 8.0
initial block dates = 512
swap broken dates = no
swap broken money = no
try server login = yes
try domain login = no
[myserver]
host = ntmachine.domain.com
port=1433
tds version = 8.0
4. Testing
1). Successfully connect to MS SQL server with IP and Port
$ ./tsql -H XXX.XX.XX.XX -p 1433 -U sa
Password:
Msg 5703, Level 0, State 1, Server MyMSServer, Line 0
Changed language setting to us_english.
1>
2). Failed to connect to MS SQL server with domain name
$ ./tsql -S domainName -U sa
Password:
src/tds/login.c: tds_connect: XXX.XX.XX.XX:4000: Connection refused
Msg 20009, Level 9, State 0, Server OpenClient, Line 0
Server is unavailable or does not exist.
There was a problem connecting to the server
Reason: Port 4000 is the compiled-in default for TDS 5.0. The reason FreeTDS is
trying port 4000 is that it's not reading your freetds.conf (or the [domainName] server section doesn't have a 'port' entry).
Unless you used the --prefix= option to the configure script, FreeTDS will look for your file in /usr/local/etc/freetds.conf. It will also
check ${HOME}/.freetds.conf (which might help you in testing, but probably not so good for your PHP server).
You can get a very verbose report of the search for freetds.conf by setting the TDSDUMPCONFIG environment variable.
3). Connected to MS SQL successfully if
$ export TDSPORT=1433
$ ./tsql -S domainName -U sa
Password:
Msg 5703, Level 0, State 1, Server MyMSServer, Line 0
Changed language setting to us_english.
1>
4). Successfully connect to MS SQL 2000 with PHP:
mssql_connect ("domainName:1433", "sa", "XXXXX");
(I have successfully connected to MS SQL 2000 Northwind database and selected
one of the table, but not Orders table.)
mssql_connect ("XXX.XX.XX.XX", "sa", "XXXXX");
Warning: mssql_connect(): Unable to connect to server: XXXX.XX.XX.XX
in ………….. on line 10
5). I have run
$ export TDSDUMP=/etc/freetds.log
but didn’t find freetds.log, don’t why.
6). I have run
$ export FREETDSCONF=/etc/freetds.conf (also tried TDSDUMPCONF)
$ ./tsql -S nomainName -U sa
Password:
src/tds/login.c: tds_connect: XXX.XX.XX.XX:4000: Connection refused
Msg 20009, Level 9, State 0, Server OpenClient, Line 0
Server is unavailable or does not exist.
There was a problem connecting to the server
-------------------------------
Here is my post and reply to freeTDS mailing list, it may help some of you.
FreeTDS@lists.ibiblio.org
---------------------Reply -----
"Lowden, James K" <LowdenJK@bernstein.com> wrote:
Q1. Since We used XAMPP (
http://www.apachefriends.org/en/) for our Apach,
PHP, MySQL setting, which has FreeTDS installed and configured by
default.
A1. OK, then you really have to talk to them. See below for the issue.
Q2. How to make freeTDS use freetds.conf instead of bypassing it?
A1: You're not "bypassing" freetds.conf when you're running Apache.
FreeTDS is linked in -- i.e. part of -- the Apache executable. What's
Happening is that FreeTDS is not finding freetds.conf because it's not where it
should be, where "should" is defined by how it was configured when it
was built.
Neither you nor I know what FreeTDS options were used at build time.
If you find that out, you'll know where to put your freetds.conf. Or, at
least, you *can* know. Right now, it's anybody's guess.
Q3. I don't know why there is no TDSDUMP log file (I have run $ export TDSDUMP=/etc/freetds.log ) and why $ export FREETDSCONF=/etc/freetds.conf doesn't work.
A3. I think what you're missing is some basic knowledge about how
Environment variables work. Even though it's a little off-topic here, I'll explain
If you'll bear with me.
When Apache starts, it's running under an account, just as you're
Running under an account when you log in. Whatever variables you set affect
Your session and no one else's, include Apache's. For those variables to
Have any effect on FreeTDS, they have to be set in Apache's session before
it starts. And the account that Apache is running under needs write
access to the file named in TDSDUMP/FREETDSCONF. I point that out because
it's unlikely that the Apache account, 'httpd' or whatever it is, will have
write access to /etc. TDSDUMP=/tmp/freetds.log might be a better
choice.