Skip to Content.
Sympa Menu

freetds - Re: [freetds] FreeTDS and PHP

freetds AT lists.ibiblio.org

Subject: FreeTDS Development Group

List archive

Chronological Thread  
  • From: "Joseph W. Losco" <joe AT sqpuv.com>
  • To: FreeTDS Development Group <freetds AT lists.ibiblio.org>
  • Subject: Re: [freetds] FreeTDS and PHP
  • Date: Thu, 20 Jan 2011 11:56:57 -0500

On Jan 11, 2011, at 6:20 PM, James Kirsop wrote:

> I'm trying to get PHP talking to a MSSQL server through FreeTDS. I can
> connect to the server via both tsql and isql on the host machine where PHP
> is installed, but can't seem to connect via PHP its self with the following
> error appearing:
> Warning: odbc_connect() [function.odbc-connect]: SQL error:
> [unixODBC][FreeTDS][SQL Server]Unable to connect to data source, SQL state
> S1000 in SQLConnect in/var/www/html/odbctest.php on line 3

When you connect with tsql and isql are you using a DSN? The way I
have it working for MSSQL 2000 is as follows.

In /etc/freetds/freetds.conf

[SERVER_NAME]
host = SERVER_IP
port = 1433
tds version = 8.0

in /etc/odbc.ini

[DATABASE_NAME]
Driver = FreeTDS
Description = DATABASE_NAME
Trace = No
Server = SERVER_IP
Port = 1433
TDS_version = 8.0
Database = DATABASE_NAME

in odbcinst.ini
[FreeTDS]
Description = FreeTDS
Driver = /usr/lib/odbc/libtdsodbc.so
Setup = /user/lib/odbc/libtdsS.so
FileUsage = 1
CPTimeout = 5
CPReuse = 5
UsageCount = 2
Trace = Yes
TraceFile = /opt/tdstrace.log


> Line 3 (the connection line of the script) is as follows - with
> usernames/passwords removed:
> $connect = odbc_connect("DARACW", "username", "pass");


I then use this line to connect to the DATABASE_NAME as the server and it
connects.


> I also get a variety of error messages following this, as a result of the
> $connect variable not being created successfully.
>
> I've looked through logs and things like that, where I would expect to find
> information but haven't found anything as yet. If anyone can offer
> suggestions on what to look at or for it would be appreciated.
>

Good luck, also if those settings are the same or similar, check firewall
rules if there is a firewall in between your MSSQL server and the webserver.

Joe
This communication is intended solely for the person addressed and is
confidential and may be privileged.
If you receive this communication incorrectly, please return it immediately
to the sender and destroy all copies in your files.
If you have questions, please contact the sender of this message.





Archive powered by MHonArc 2.6.24.

Top of Page