Re: Bug #641: Extra whitespace when SELECTing a text field

From: Date: Mon, 10 Aug 1998 23:19:55 +0000
Subject: Re: Bug #641: Extra whitespace when SELECTing a text field
References: 1  Groups: php.dev 
Request: Send a blank email to php-dev+get-85@lists.php.net to get a copy of this message
At 18:24 10/08/98 -0000, cbi@allgaeu.org wrote: >From: cbi@allgaeu.org >Operating system: Linux 2.0.34 >PHP version: 3.0.2a >PHP Bug Type: Sybase related >Bug description: >I noticed that sometimes PHP seems to append some extra whitespace to fields selected from a MS-SQL-database. I wasn't able to find out WHY it happens, but I am pretty sure I am able to reproduce this behavior. > >Sybase Open/C client 10.0.3, Apache 1.3.1 > >The problem: I SELECT a field from the Database: > >$res = sybase_query("select name from item",$db); >$result = sybase_fetch_array($res); > >and when I try $result["name"] or $result[0] it contains > >"blbla " <--- extra whitespace > >I am sure that there are no blanks behind the words in the database. The length of the whole string is IMHO approximately equal to the length of the field in the database. It is a littel bit strange that it happens only sometimes but when it happens, I can always reproduce it. When SELECTing more than one row not every field has extra whitespace. This has to do with the say SQL database are allowed to store textual data. Padding the text with spaces is allowed. Now, as far as I recall, I'm not doing anything special to get rid of trailing spaces. The question is, then, if you see different behaviors for two identical field types, e.g. char(10). Numeric data, as well as binary data, will never be padded with spaces; textual data would. Let me know - if there's a problem, I'll need some reproduceable case, including a database dump. Zeev -- Zeev Suraski <zeev@php.net> For a PGP public key, finger bourbon@netvision.net.il -- PHP Development Mailing List http://www.php.net/ To unsubscribe send an empty message to php-dev-unsubscribe@lists.php.net For help: php-dev-help@lists.php.net

« previous php.dev (#85) next »