[freetds] how can i use freetds.conf with PHP?

Lowden, James K LowdenJK at bernstein.com
Tue May 6 11:38:17 EDT 2003


> From: Spyros Ioakim [mailto:sioakim at atlas.ace-hellas.gr]
> Sent: May 6, 2003 3:15 AM
> 
> I just upgraded to the nightly build and solved my problems with long
> queries that I had.
> The problem now is that I can't insert or update a field with Greek
> characters (I get english characters with ? like mentioned in the faq)
> I read in the manual that you need something like the following:
>  
> [mssql]
>         host = 192.168.2.221
                 ^^^^^^^^^^^^^ normally the server's hostname
>         port = 1433
>         tds version = 7.0
>         client charset = GREEK
                           ^^^^^ 
That's the same as ISO-8859-7 and different from CP1253.  

> so my PHP code is as simple as that:
>  
> putenv('TDSVER=7.0');
> putenv('FREETDSCONF=/usr/local/freetds/etc/freetds.conf');
> $connectid = mssql_connect("mssql" , "sa" ,"sa" );
> $r = mssql_select_db ("icad");
> $query="update icad_weather_sun set hmeromhnia='$hmnia',
> giortazoyn='$output', eorth='$eorth' where date_entered='2'";
> $result = mssql_query ($query);
> 
> the values of $output and $eorth are in Greek.
>  
> Problem is that php can't locate the server.

You mean FreeTDS can't locate the server?  Try TDSDUMPCONFIG, if that's the
issue.  

In another log you posted, I note the client charset is ISO-8859-1, the
default (Latin1 and not, as you know, Greek).  That would be consistent with
your report: iconv would read your Greek text, encoded in ISO-8859-7, and
attempt to interpret it according to ISO-8859-1, yielding some Roman
characters and some invalid values.  Blech!  Trick is to persuade FreeTDS
that the client is using ISO-8859-7.  

Two questions:

1.  What is the server character set?
2.  Are the columns holding Greek text in the tables defined as varchar or
nvarchar?  

Right now, FreeTDS still does not use iconv to convert single-byte character
data -- however encoded -- meaning that [var]char and text columns must use
the same encoding as does the client.   This will change in the (probably
near, certainly approaching) future.  We recently started handling,
experimentally, UTF-8 client data, but we're far from done with that.  

Regards, 

--jkl


The information contained in this transmission may contain privileged and
confidential information and is intended only for the use of the person(s)
named above.  If you are not the intended recipient, or an employee or agent
responsible for delivering this message to the intended recipient, any
review, dissemination, distribution or duplication of this communication is
strictly prohibited. If you are not the intended recipient, please contact
the sender immediately by reply e-mail and destroy all copies of the
original message. Please note that we do not accept account orders and/or
instructions by e-mail, and therefore will not be responsible for carrying
out such orders and/or instructions.





More information about the FreeTDS mailing list