[freetds] Problems executing a query

ZIGLIO, Frediano, VF-IT Frediano.Ziglio at vodafone.com
Fri Jun 17 08:55:39 EDT 2005


> 
> James K. Lowden ha scritto:
> > Riccardo Penco wrote:
> > 
> >>If in a php script I write:
> >>
> >>$sql = "SELECT Città from PDV";
> >>$res = mssql_query($sql, $conn);
> >>
> >>I obtain the following error message:
> >>Warning: mssql_query(): Error converting client characters 
> into server's
> >>
> >>character set. Some character(s) could not be converted. 
> (severity 16)
> > 
> > 
> > Does the query work in tsql?  It should.  
> 
> Yes, it works
> 
> and note that if I connect using "SERVER_NAME" as configured in 
> freetds.conf (ie tds version = 8.0 and client charset = 
> UTF-8) then the 
> script doesn't works BUT if I use the IP address (ie using 
> tds version = 
> 4.2) then it works!
> 
> $conn = mssql_connect("SERVER_NAME", user, pass) => doesn't work
> 
> $conn = mssql_connect("IP_ADDRESS", user, pass) => works
> 
> > SQL Server 2000 encodes database object names in UCS-2, 
> which obviously
> > can represent 'Città'.  The error message may be telling 
> you that the à is
> > arriving not as UTF-8 (2 bytes) but as ISO 8859-1 (1 byte, 
> high bit on). 
> > Attempting to interpret ISO 8859-1 as UTF-8 will elicit 
> that message.  
> > 
> > A TDSDUMP log will provide more detailed information about 
> the failed
> > conversion.  
> 
> I've attached the log file (hope is the right thing to do)
> 

Thanks

As I suggested client (PHP in this case) is not using utf8!

14:30:39.828341 tds_put_string converting 51 bytes of "à FROM PDV where città like '%cant%' ORDER BY Città"
14:30:39.828372 Error: tds_put_string: Gave up converting 51 bytes due to error 84.
	Troublesome bytes:
	0000 e0 20 46 52 4f 4d 20 50-44 56 20 77 68 65 72 65 |. FROM P DV where|

0xe0 is 'à' in iso8859-1, windows1252 and similar but not in utf8.
FreeTDS correctly give the error.
But IMO it should not send partial converted query !!!

freddy77



More information about the FreeTDS mailing list