ID: 33123 Updated by: [EMAIL PROTECTED] Reported By: rober_box at mailforce dot net -Status: Assigned +Status: Suspended Bug Type: MySQL related Operating System: Gentoo Linux 2005.0 PHP Version: 4.3.11 Assigned To: georg New Comment:
Currently MySQL client library doesn't provide an API call to retrieve CHARSET_INFO structure for a specific character set. So on client side there is currently no way to determine the maximum size in bytes and characters. This will probably be added into MySQL 5.1 Previous Comments: ------------------------------------------------------------------------ [2005-05-24 14:02:10] [EMAIL PROTECTED] Doesn't look like a PHP problem to me. Georg, please confirm it. ------------------------------------------------------------------------ [2005-05-24 12:39:05] rober_box at mailforce dot net Description: ------------ mysql_field_len() doesn't return the correct field len for utf-8 fields. Instead it returns the maximum length mysql allows (i.e 3 bytes). That way i can't check user input for length sanity. My configuration: './configure' '--prefix=/usr' '--host=i686-pc-linux-gnu' '--mandir=/usr/share/man' '--infodir=/usr/share/info' '--datadir=/usr/share' '--sysconfdir=/etc' '--localstatedir=/var/lib' '--with-apxs2=/usr/sbin/apxs2' '--without-db3' '--without-db4' '--without-db2' '--without-ndbm' '--with-mcrypt=/usr' '--with-mhash=/usr' '--without-interbase' '--without-ming' '--without-swf' '--without-sybase' '--with-gdbm=/usr' '--without-fdftk' '--without-java' '--without-mcal' '--without-unixODBC' '--without-pgsql' '--without-snmp' '--with-xpm-dir=/usr/X11R6' '--without-gmp' '--without-mssql' '--with-pdflib=/usr' '--with-gd' '--enable-gd-native-ttf' '--with-png=/usr' '--with-png-dir=/usr' '--with-jpeg=/usr' '--with-jpeg-dir=/usr' '--enable-exif' '--with-tiff=/usr' '--with-tiff-dir=/usr' '--with-mysql=/usr' '--with-mysql-sock=/var/run/mysqld/mysqld.sock' '--with-freetype-dir=/usr' '--with-ttf=/usr' '--with-t1lib=/usr' '--with-gettext' '--with-qtdom=/usr/qt/3' '--with-pspell=/usr' '--with-openssl=/usr' '--without-imap' '--without-ldap' '--with-dom=/usr' '--with-dom-xslt=/usr' '--with-dom-exslt=/usr' '--without-kerberos' '--with-pam' '--disable-memory-limit' '--enable-ipv6' '--without-yaz' '--disable-debug' '--with-curlwrappers' '--with-curl=/usr' '--enable-dbx' '--with-zlib=/usr' '--with-zlib-dir=/usr' '--with-sablot=/usr' '--enable-xslt' '--with-xslt-sablot' '--with-xmlrpc' '--enable-wddx' '--with-xml' '--enable-mbstring=all' '--enable-mbregex' '--with-bz2=/usr' '--with-crack=/usr' '--with-cdb' '--enable-pcntl' '--enable-bcmath' '--enable-calendar' '--enable-dbase' '--enable-filepro' '--enable-ftp' '--with-mime-magic=/usr/share/misc/file/magic.mime' '--enable-sockets' '--enable-sysvsem' '--enable-sysvshm' '--enable-sysvmsg' '--with-iconv' '--enable-shmop' '--enable-dio' '--enable-yp' '--without-ncurses' '--without-readline' '--enable-inline-optimization' '--enable-track-vars' '--enable-trans-sid' '--enable-versioning' '--with-config-file-path=/etc/php/apache2-php4' '--without-pear' '--libdir=/usr/lib/php' '--with-pear=/usr/lib/php' Reproduce code: --------------- $fields = mysql_list_fields($link, $table) or msg_error(mysql_error()); $len = mysql_field_len($fields, $i); echo $len; Expected result: ---------------- I expect to see the actual length as shown by issuing a SHOW FIELDS FROM table query. For example if a field is VARHCHAR(8) i expect to see 8, not 24. Actual result: -------------- 24 ------------------------------------------------------------------------ -- Edit this bug report at http://bugs.php.net/?id=33123&edit=1
