Edit report at https://bugs.php.net/bug.php?id=62426&edit=1
ID: 62426 Updated by: u...@php.net Reported by: robert dot butler at hoa-management dot com Summary: mysqli_fetch_field_direct returns incorrect length on UTF8 fields -Status: Open +Status: Not a bug Type: Bug Package: MySQLi related Operating System: Linux PHP Version: Irrelevant Block user comment: N Private report: N New Comment: Thank you for taking the time to write to us, but this is not a bug. Please double-check the documentation available at http://www.php.net/manual/ and the instructions on how to report a bug at http://bugs.php.net/how-to-report.php Returns bytes Previous Comments: ------------------------------------------------------------------------ [2012-06-26 21:48:24] robert dot butler at hoa-management dot com 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 this bug report at https://bugs.php.net/bug.php?id=62426&edit=1