From: robert dot butler at hoa-management dot com
Operating system: Linux
PHP version: Irrelevant
Package: MySQLi related
Bug Type: Bug
Bug description:mysqli_fetch_field_direct returns incorrect length on UTF8
fields
Description:
------------
When using UTF8 in the database (mySQL 5.5.24-0ubuntu0.12.04.1), fields
defined as a certain length aren't returned as the correct length by
mysqli_fetch_field_direct. IOW, a char(32) field is shown as actually being
96 chars long because it's 32 * 3 (3 bytes per char instead of one).
The older mysql_field_len correctly reports the length.
Test script:
---------------
// Assuming a single table with a single field 'test' defined as char(32)
// and UTF-8 charset.
$connection = = mysqli_connect ('localhost', 'user', 'password');
$query = "SELECT test FROM test_table LIMIT 1";
$result = mysqli_query ($connection, $query);
$field_info = mysqli_fetch_field_direct ($result, 0);
echo $field_info -> length;
Actual result:
--------------
Returns 96; should be 32.
--
Edit bug report at https://bugs.php.net/bug.php?id=62426&edit=1
--
Try a snapshot (PHP 5.4):
https://bugs.php.net/fix.php?id=62426&r=trysnapshot54
Try a snapshot (PHP 5.3):
https://bugs.php.net/fix.php?id=62426&r=trysnapshot53
Try a snapshot (trunk):
https://bugs.php.net/fix.php?id=62426&r=trysnapshottrunk
Fixed in SVN:
https://bugs.php.net/fix.php?id=62426&r=fixed
Fixed in SVN and need be documented:
https://bugs.php.net/fix.php?id=62426&r=needdocs
Fixed in release:
https://bugs.php.net/fix.php?id=62426&r=alreadyfixed
Need backtrace:
https://bugs.php.net/fix.php?id=62426&r=needtrace
Need Reproduce Script:
https://bugs.php.net/fix.php?id=62426&r=needscript
Try newer version:
https://bugs.php.net/fix.php?id=62426&r=oldversion
Not developer issue:
https://bugs.php.net/fix.php?id=62426&r=support
Expected behavior:
https://bugs.php.net/fix.php?id=62426&r=notwrong
Not enough info:
https://bugs.php.net/fix.php?id=62426&r=notenoughinfo
Submitted twice:
https://bugs.php.net/fix.php?id=62426&r=submittedtwice
register_globals:
https://bugs.php.net/fix.php?id=62426&r=globals
PHP 4 support discontinued:
https://bugs.php.net/fix.php?id=62426&r=php4
Daylight Savings: https://bugs.php.net/fix.php?id=62426&r=dst
IIS Stability:
https://bugs.php.net/fix.php?id=62426&r=isapi
Install GNU Sed:
https://bugs.php.net/fix.php?id=62426&r=gnused
Floating point limitations:
https://bugs.php.net/fix.php?id=62426&r=float
No Zend Extensions:
https://bugs.php.net/fix.php?id=62426&r=nozend
MySQL Configuration Error:
https://bugs.php.net/fix.php?id=62426&r=mysqlcfg