Hello,
You should add a section to your freetds.conf file that looks something
like this:
[MyHost]
host = 192.168.55.3
port = 1433
tds version = 8.0
And they set $dbhost = "MyHost"; in your php script.
- Frank
Hello,
I have a Linux server that's running PHP 4.4.0 and 5.2.0 along with
FreeTDS 0.64I am trying to connect to a MS SQL Server 2005 with PHP and I
encounter a problem. Here is the php script content:$dbhost = "192.168.55.3:1433"; $dbuser = "sa"; $dbpass = "samepassword"; $db = mssql_connect($dbhost,$dbuser,$dbpassword) or die("Unable to
connect to server");
Output of runnign script:
<br />
<b>Warning</b>: mssql_connect() [<a href='function.mssql-connect'>function.mssql-connect</a>]: message: Login
failed for user 'sa'. (severity 14) in <b>/bin/pipe.php</b> on line
<b>7</b><br />
<br />
<b>Warning</b>: mssql_connect() [<a href='function.mssql-connect'>function.mssql-connect</a>]: Unable to
connect to server: 192.168.55.3:1433 in <b>/bin/pipe.php</b> on line
<b>7</b><br />Anyway if I am logging using tsql it works:
[root@softlink bin]# tsql -C
Compile-time settings (established with the "configure" script):
Version: freetds v0.64
MS db-lib source compatibility: yes
Sybase binary compatibility: unknown
Thread safety: yes
iconv library: yes
TDS version: 8.0
iODBC: no
unixodbc: no[root@softlink bin]# tsql -S 192.168.55.3 -U sa
locale is "en_US.UTF-8"
locale charset is "UTF-8"
Password:
1>The freetds.log files are different in each case:
[working - running by tsql]
....
02:30:59.504763 1052 (iconv.c:361):iconv to convert client-side data to
the "UTF-8" character set
02:30:59.504906 1052 (iconv.c:514):tds_iconv_info_init: converting
"UTF-8"->"UCS-2LE"
02:30:59.505100 1052 (iconv.c:514):tds_iconv_info_init: converting
"ISO-8859-1"->"UCS-2LE"
02:30:59.505193 1052 (net.c:168):Connecting to 192.168.55.3 port 1433.
02:30:59.505951 1052 (write.c:134):tds_put_string converting 8 bytes of
"softlink"
02:30:59.506271 1052 (write.c:162):tds_put_string wrote 16 bytes
02:30:59.506321 1052 (write.c:134):tds_put_string converting 2 bytes of
"sa"
02:30:59.506360 1052 (write.c:162):tds_put_string wrote 4 bytes
02:30:59.506398 1052 (write.c:134):tds_put_string converting 4 bytes of
"TSQL"
02:30:59.506434 1052 (write.c:162):tds_put_string wrote 8 bytes
02:30:59.506467 1052 (write.c:134):tds_put_string converting 12 bytes of
"192.168.55.3"
02:30:59.506503 1052 (write.c:162):tds_put_string wrote 24 bytes
02:30:59.506536 1052 (write.c:134):tds_put_string converting 11 bytes of
"TDS-Library"
02:30:59.506571 1052 (write.c:162):tds_put_string wrote 22 bytes
02:30:59.506604 1052 (write.c:134):tds_put_string converting 10 bytes of
"us_english"
02:30:59.506640 1052 (write.c:162):tds_put_string wrote 20 bytes
02:30:59.506673 1052 (write.c:162):tds_put_string wrote 0 bytes
02:30:59.506849 1052 (token.c:310):tds_process_login_tokens()
02:30:59.508366 1052 (net.c:446):Received header
0000 04 01 01 95 00 33 01 00- |.....3..|[non working - running by php]
....
02:31:37.444823 1059 (iconv.c:361):iconv to convert client-side data to
the "ISO-8859-1" character set
02:31:37.444969 1059 (iconv.c:514):tds_iconv_info_init: converting
"ISO-8859-1"->"UCS-2LE"
02:31:37.445067 1059 (iconv.c:514):tds_iconv_info_init: converting
"ISO-8859-1"->"UCS-2LE"
02:31:37.445145 1059 (net.c:168):Connecting to 192.168.55.3 port 1433.
02:31:37.446876 1059 (write.c:134):tds_put_string converting 8 bytes of
"softlink"
02:31:37.447186 1059 (write.c:162):tds_put_string wrote 16 bytes
02:31:37.447269 1059 (write.c:134):tds_put_string converting 2 bytes of
"sa"
02:31:37.447311 1059 (write.c:162):tds_put_string wrote 4 bytes
02:31:37.447349 1059 (write.c:134):tds_put_string converting 7 bytes of
"PHP 4.0"
02:31:37.447385 1059 (write.c:162):tds_put_string wrote 14 bytes
02:31:37.447418 1059 (write.c:134):tds_put_string converting 12 bytes of
"192.168.55.3"
02:31:37.447453 1059 (write.c:162):tds_put_string wrote 24 bytes
02:31:37.447485 1059 (write.c:134):tds