Skip to Content.
Sympa Menu

freetds - [freetds] SQL error during odbc_connect in PHP using FreeTDS

freetds AT lists.ibiblio.org

Subject: FreeTDS Development Group

List archive

Chronological Thread  
  • From: "stanislav puffler" <stanislav.puffler AT eficia.cz>
  • To: <freetds AT lists.ibiblio.org>
  • Subject: [freetds] SQL error during odbc_connect in PHP using FreeTDS
  • Date: Wed, 4 Jan 2006 14:27:09 +0100

Hi,
have installed FreeTDS (freetds_mssql0 packages - 0.64 and unixODBC) into my
Linux Box (Mandriva 2006 free) and want to use it on my intranet (Apache,
PHP) to connect to remote host with MS SQL Server 2000 running on Windows
2000 Server.
TSQL utility is succesful without problem.

------------------------------------------------------------------
[puffler@blackmarket ~]$ tsql_mssql -S solidus -U user -P password
locale is "cs_CZ"
locale charset is "ISO-8859-2"
1>
------------------------------------------------------------------

So I have installed php-odbc package and unixODBC. Also configuration of DSN
was succesful, because of :

------------------------------------------------------------------
[puffler@blackmarket ~]$ isql nextccdb user password
+---------------------------------------+
| Connected! |
| |
| sql-statement |
| help [tablename] |
| quit |
| |
+---------------------------------------+
SQL>
------------------------------------------------------------------

Here is my configuration in /etc :

1) freetds_mssql.conf

[solidus]
host = solidus.eficia.cz
port = 1433
tds version = 7.0
client charset = ISO-8859-2

2) odbc.ini

[nextccdb]
Description = MSSQLServer
Driver = MSSQLServer
Servername = solidus
Server = solidus.eficia.cz
Address = 192.168.0.10
Port = 1433
Database = nextccdb
TDS_Version = 8.0
Language = us_english
TextSize =
Domain = eficia.cz
PacketSize =

But the only one problem is when I want to finish my mission and connect to
MS SQL via PHP script and odbc_connect function from intranet, I get an
error. The script is like this :

------------------------------------------------------------------
<?php
// connect to DSN MSSQL with a user and password
$connect = odbc_connect("nextccdb", "user", "password") or die
("couldn't connect");
odbc_exec($connect, "use kk_c_code");
$result = odbc_exec($connect, "SELECT name, active " .
"FROM kk_c_code");
while(odbc_fetch_row($result)){
print(odbc_result($result, "name") .
' ' . odbc_result($result, "active") . "<br>\n");
}
odbc_free_result($result);
odbc_close($connect);
?>
------------------------------------------------------------------

Here is what I get - after about 15 seconds of script running, it is timed
out with this :

------------------------------------------------------------------
Warning: odbc_connect() [function.odbc-connect]: SQL error: Unexpected
protocol character during authentication; Error while reading from the
socket., SQL state 28000 in SQLConnect in /var/www/html/vytaceni/mssql.php on
line 3
couldn't connect
------------------------------------------------------------------

What do I need to change for succesful connection ? Thanks a lot for your
suggestion. Best regards,

Stanislav Puffler
IT Specialist - Eficia Praha spol. s r.o.




Archive powered by MHonArc 2.6.24.

Top of Page