[freetds] SQL error during odbc_connect in PHP using FreeTDS

stanislav puffler stanislav.puffler at eficia.cz
Wed Jan 4 09:41:05 EST 2006


Thanks for your idea, have changed my freetds_mssql.conf and now I have 8.0 version of TDS. Also odbc.ini is now defined easier, as for odbcinst.ini it is like this :

----------------------------
[MSSQLServer]
Description     = ODBC for MS SQL Server via FreeTDS
Driver          = /usr/lib/libtdsodbc_mssql.so.0
Driver64        = /usr/lib
Setup           = /usr/lib/libtdsodbc_mssql.so.0.0.0
Setup64         = /usr/lib
UsageCount      = 1
CPTimeout       =
CPReuse         =
----------------------------

Have tried to run my script also from shell and it return the same error. When I use TDSDUMPCONFIG=stdout php mssql.php or TDSDUMP=stdout php mssql.php - mentioned error is there two times. Also tried to change my freetds_mssql.conf and appended this :

----------------------------
dump file = /tmp/freetds.log
dump file append = yes
----------------------------

But after running script few times there is nothing in /tmp :o(

SP

-----Pùvodní zpráva-----
Od:	freetds-bounces at lists.ibiblio.org za uživatele ZIGLIO, Frediano, VF-IT
Odesláno:	st 4.1.2006 14:55
Komu:	FreeTDS Development Group
Kopie:	
Pøedmìt:	Re: [freetds] SQL error during odbc_connect in PHP using FreeTDS
> 
> 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 at 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 at 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
_______________________________________________
FreeTDS mailing list
FreeTDS at lists.ibiblio.org
http://lists.ibiblio.org/mailman/listinfo/freetds



-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/ms-tnef
Size: 5253 bytes
Desc: not available
Url : http://lists.ibiblio.org/pipermail/freetds/attachments/20060104/910d8ab4/attachment.bin


More information about the FreeTDS mailing list