php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #44076 mysql_result returns nothing with blob
Submitted: 2008-02-08 08:12 UTC Modified: 2010-04-07 19:01 UTC
Votes:3
Avg. Score:4.0 ± 0.8
Reproduced:3 of 3 (100.0%)
Same Version:1 (33.3%)
Same OS:1 (33.3%)
From: jeff76 at operamail dot com Assigned: mysql (profile)
Status: Wont fix Package: MySQL related
PHP Version: 6CVS-2008-02-08 (snap) OS: FreeBSD
Private report: No CVE-ID: None
Have you experienced this issue?
Rate the importance of this bug to you:

 [2008-02-08 08:12 UTC] jeff76 at operamail dot com
Description:
------------
It seems using mysql_result to retrieve a blob doesn't work and returns nothing (NULL). Using a different function like mysql_fetch_assoc however does work properly, as does reverting to PHP 5 or retrieving a non-blob column.

This is using Unicode semantics.

Reproduce code:
---------------
(...connect to DB)

$res=mysql_query('SELECT blob_column FROM table WHERE condition');
$var=mysql_result($res, 0);
print_r($var);
echo(gettype($var));


Expected result:
----------------
(random binary garbage) and a proper variable type (unicode or binary ?)


Actual result:
--------------
gettype returns NULL, and print_r echoes nothing.

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2008-02-12 21:13 UTC] felipe@php.net
Works fine to me.
PHP 6.0.0-dev (cli) (built: Feb 12 2008 18:56:58)
 [2008-02-14 13:21 UTC] jeff76 at operamail dot com
I did further testing, it seems the bugs shows up or not depending on the blob field content itself :
- it works fine if the content is text (tried with both short strings as well as 100 Kb+ ISO-8859-1 text files)
- it doesn't work with raw binary content (such as a JPEG file, however short or long)

Also this is using MySQL 4.1 and InnoDB tables.
 [2008-03-25 19:22 UTC] andrey@php.net
Yes, this issue is known, it only manifests when unicode.semantics=one
Here is an excerpt from the sources :


/* XXX: What about unicode type ??? Please test :) */
switch(Z_TYPE_PP(field)) {
	case IS_STRING: {

It has been tested, as you also did, and it doesn't work. The code should be ported to PHP6 Unicode but how to do it is out of my area of expertise of working with Unicode+Zend :(
 [2010-04-07 19:01 UTC] andrey@php.net
-Status: Assigned +Status: Wont fix
 [2010-04-07 19:01 UTC] andrey@php.net
As HEAD is not unicode anymore this bug won't be fixed and doesn't exist in HEAD(trunk) anymore.
 
PHP Copyright © 2001-2021 The PHP Group
All rights reserved.
Last updated: Thu Sep 16 19:03:38 2021 UTC