Skip to Content.
Sympa Menu

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

freetds AT lists.ibiblio.org

Subject: FreeTDS Development Group

List archive

Chronological Thread  
  • From: "ZIGLIO, Frediano, VF-IT" <Frediano.Ziglio AT vodafone.com>
  • To: "FreeTDS Development Group" <freetds AT lists.ibiblio.org>
  • Subject: Re: [freetds] SQL error during odbc_connect in PHP using FreeTDS
  • Date: Wed, 4 Jan 2006 14:55:50 +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.
>

freetds_mssql0 0.64 ?? Well, not an official version but we will try to
help you.

> ------------------------------------------------------------------
> [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
>

correct. Our version use freetds.conf but I think they change to
freetds_mssql.conf to avoid some sort of collision. Note that you should
use tds version 8.0 here.

> 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 =
>

??? a bit too long... do not use Server and Servername first. Domain is
obsolete. Remove TextSize and PacketSize, useless. Does odbcinst.ini
contain a MSSQLServer entry ? Try with an easier

[nextccdb]
Driver = MSSQLServer
Servername = solidus
Database = nextccdb

> 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
> ------------------------------------------------------------------
>

Quite strange. Have you tried using PHP from shell? Simply run php
script.php. If packager do not strip debugging you could also enable
some tracing with

TDSDUMPCONFIG=stdout php script.php

or even

TDSDUMP=stdout php script.php

> 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.
>

bye
freddy77




Archive powered by MHonArc 2.6.24.

Top of Page