Bug #51189 [Fbk->Bgs]: mysql_field_len reporting value incorrectly

From: Date: Mon, 27 Sep 2010 09:06:27 +0000
Subject: Bug #51189 [Fbk->Bgs]: mysql_field_len reporting value incorrectly
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-154668@lists.php.net to get a copy of this message
Edit report at http://bugs.php.net/bug.php?id=51189&edit=1 ID: 51189 Updated by: uw@php.net Reported by: ste dot sullivan at gmail dot com Summary: mysql_field_len reporting value incorrectly -Status: Feedback +Status: Bogus Type: Bug Package: MySQL related Operating System: Gentoo PHP Version: Irrelevant Assigned To: mysql Block user comment: N New Comment: Well, 99.9% sure it is bogus. Let's close. mysql_field_len returns MYSQL_FIELD->lenght (C API), which is "The width of the field. This corresponds to the display length, in *bytes*.". The reporter seems to use a CHAR(50) (resp. CHAR(255)) SQL column together with a 3 byte charset: 50 character x 3 bytes per character = 150 bytes. Previous Comments: ------------------------------------------------------------------------ [2010-03-22 09:33:46] uw@php.net Please send DDL = table definition = schema of table "mytable". Thanks! ------------------------------------------------------------------------ [2010-03-21 19:34:39] felipe@php.net Please, post the DDL used to create the table. ------------------------------------------------------------------------ [2010-03-03 02:30:03] ste dot sullivan at gmail dot com Ooops - The second expected result should be: Phone { string ( 16 ) } The version information also seems to have been wiped from my original post: PHP: 5.2.12-pl0-gentoo MYSQL Client API: 5.0.84 ------------------------------------------------------------------------ [2010-03-03 02:01:13] ste dot sullivan at gmail dot com Description: ------------ I am using Gentoo Test script: --------------- $db=mysql_connect("localhost","user","pass"); $q=mysql_query("SELECT * FROM mytable"); for($i=0;$i<mysql_num_fields($q);$i++) { $fnames[$i]=mysql_field_name($q,$i); echo $fnames[$i]." { ".mysql_field_type($q,$i)." ( ".mysql_field_len($q,$i)." ) }\n"; } Expected result: ---------------- Name { string ( 50 ) } Phone { string ( 48 ) } Email { string ( 255 ) } Actual result: -------------- Name { string ( 150 ) } Phone { string ( 48 ) } Email { string ( 765 ) } ------------------------------------------------------------------------ -- Edit this bug report at http://bugs.php.net/bug.php?id=51189&edit=1

« previous php.bugs (#154668) next »