Click to See Complete Forum and Search --> : Connecting Redhat/Apache/PHP to MSSQL


chadu
06-24-2003, 08:15 PM
I am attempting to setup a Redhat Linux 9 box with PHP 4.2.2 and Apache 2.0.40 to connect with a MSSQL server database using FreeTDS. This has been headache after headache.

i am able to connect with tsql fine. My ODBC connection scripts from PHP on the other hand are a bit different...

I am currently getting the following error:
SQL error: [unixODBC]Client unable to establish connection, SQL state S1000 in SQLConnect in /var/www/html/rossmach/odbc_test.php

the error is coming from this statement:
$connection = odbc_connect("Driver=TDS;Server=192.168.0.3:1433;Database=ARMCODATA", "username", "password", "Integrated Security=NO") or
die(odbc_error());

My freetds.conf file contains this info for the DSN:
[TDS]
host = 192.168.0.3
port = 1433
tds version = 4.2



Any ideas on what I am doing wrong? Any help is very welcome.

Doug G
06-25-2003, 03:01 AM
Try tds version = 7.0 for SQL Server 7.0, or tds version = 8.0 for SQL Server 2000

I use a DSN, I don't see anywhere in the PHP docs that indicates you can use a connection string as an argument to odbc_connect()

I used freeTDS 0.61 rpm's for RedHat I found on the web rather than building freeTDS. I'm on RH 8

bozidar
08-06-2003, 10:35 AM
I am stuck with the same situation...however it is my conclusion that the problem is originating in unixODBC, not the freetds. The tests i ran are as follows:

/usr/local/freetds/bin/tsql -S MyServer70 -U sa
locale is "en_US.UTF-8"
charset is "UTF-8"
Password:
Msg 5703, Level 0, State 1, Server ACSSQL, Line 0
Changed language setting to us_english

This was successful...however:

# isql -v MyServer70 sa password
[unixODBC]Client unable to establish connection
[ISQL]ERROR: Could not SQLConnect

This is completely wrong...

My config files are as follows:

[root@skopjanka etc]# cat /etc/odbcinst.ini
[PostgreSQL]
Description = ODBC for PostgreSQL
Driver = /usr/lib/libodbcpsql.so
Setup = /usr/lib/libodbcpsqlS.so
FileUsage = 1

[TDS]
Description = v0.52 with protocol v4.2
Driver = /usr/local/freetds/lib/libtdsodbc.so
FileUsage = 1

cat /etc/odbc.ini
[MyServer70]
Driver = TDS
Description = Northwind sample database
Trace = No
Servername = 195.26.152.120
Database = Northwind
UID = sa

I am utterly stuck and have no idea what to do