[thelist] [MSSQL] - connection from PHP
Ron Dorman
rwd at csi1st.net
Mon Sep 15 09:53:47 CDT 2003
Paul Bennett wrote:
> [snip]
>
> I have the alias "Server" set up on freetds.conf, with the settings:
> [Server]
> host = 192.168.1.4
> port = 1433
> tds version = 7.0
>
> and have set the environment vars at the beginning of my php script:
> putenv("SYBASE=/usr/local/freetds");
> putenv("TDSVER=7.0");
>
> when I try to use mssql_connect ( 'Server', 'Paul', 'Bennett') the
> script fails silently - the connection function returns false, but
> there is no data in mssql_get_last_message ().
>
> As an experiment, when I try to connect using mssql_connect (
> '192.168.1.4', 'Server', 'Paul') I get:
> Sybase message: Login failed for user 'SERVER\Guest'. (severity 14)
>
> As another experiment, when I try to connect using mssql_connect (
> '192.168.1.4,1433', 'Server', 'Paul') - adding port 1433 to the end of
> the ip string It fails silently again.
>
> Any ideas how I can figure out how to connect?
Hi Paul,
Here are few snippets I dug up trying to get RH 9, Apache 2, php, SSL
talking to a MSSQL server. Maybe something here will spark an idea or
provide and answer for you. I still don't have mine running, getting
connection refused accessing the server with https protocol, so I can't
tell you anything solid.
1.
Add the following to your freetds.conf and you wont need the
"1.2.3.4:1433" stuff that was posted by others.
[MsSqlServer]
host = 1.2.3.4
port = 1433
tds version = 7.0
text size = 147483647
You can use "MsSqlServer" to connect.I had problem mssql_bind, so I gave
"EXEC ProcedureFoo @Foo = foo;"
to mssql_query and it worked.
Like others have mentioned, you would want to change the text size in
order to get anything bigger than 4kb.I made my mssql.textsize = 147483647.
2.
You need to compile your FreeTDS based on what MsSQL server version you
are using. When compiling use the flags --with-tdsver= and then append
the MsSQL version you are using. For MsSQL 2000, its 7.0.
3.
We compiled PHP with "--with-mssql=/usr/local/freetds", and found that
we could only mssql_connect using the IP:port syntax, not the name we
defined in freetds.conf.
To fix this, we added to the /usr/local/apache2/bin/envvars file:
FREETDSCONF="/usr/local/freetds/etc/freetds.conf"
export FREETDSCONF
4.
Its possible to change the default connection type from Named Pipes to
TCP/IP
WITHOUT installing the Connectivity-Part from the MSSQL7 Server-cd,
The registry-key,
[HKEY_LOCAL_MACHINE\SOFTWARE\
Microsoft\MSSQLServer\Client\ConnectTo]
holds the current connection-type.
Initially its set to "DSQUERY"="DBNMPNTW" which corresponds to Named Pipes.
Change it to "DSQUERY"="DBMSSOCN" which corresponds to TCP/IP.
(Only tested on Win2KPro)
Hope something helps,
Ron D.
More information about the thelist
mailing list