php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #62426 mysqli_fetch_field_direct returns incorrect length on UTF8 fields
Submitted: 2012-06-26 21:48 UTC Modified: 2012-07-02 13:28 UTC
From: robert dot butler at hoa-management dot com Assigned:
Status: Not a bug Package: MySQLi related
PHP Version: Irrelevant OS: Linux
Private report: No CVE-ID: None
View Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
If you reported this bug, you can edit this bug over here.
(description)
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: robert dot butler at hoa-management dot com
New email:
PHP Version: OS:

 

 [2012-06-26 21:48 UTC] 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.


Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2012-07-02 13:28 UTC] uw@php.net
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
 [2012-07-02 13:28 UTC] uw@php.net
-Status: Open +Status: Not a bug
 [2015-07-06 11:53 UTC] cweiske@php.net
PHP 5.2 actually returned the correct length, while 5.3, 5.4, 5.5 and 5.6 return the triple size.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Sat Dec 21 12:01:31 2024 UTC