php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #43674 cannot insert image file blob_id in the table
Submitted: 2007-12-25 16:09 UTC Modified: 2009-08-13 09:25 UTC
From: kaf at p dot pt Assigned:
Status: Closed Package: InterBase related
PHP Version: 5.2.5 OS: Windows Server 2003
Private report: No CVE-ID: None
View Add Comment Developer Edit
Anyone can comment on a bug. Have a simpler test case? Does it work for you on a different platform? Let us know!
Just going to say 'Me too!'? Don't clutter the database with that please !
Your email address:
MUST BE VALID
Solve the problem:
45 - 16 = ?
Subscribe to this entry?

 
 [2007-12-25 16:09 UTC] kaf at p dot pt
Description:
------------
When i try to import a TIF file to a BLOB colunn in a table with a BLOB field subtype 1 in Firebird 2.0.2, always gives error.

Always gives the BLOB ID invalide when executes ibase_execute. But i checked if the BLOB is well created using the ibase_blob_info and it is okay.
Can you explain me why this does not work? 
I saw some other bugs reported in 2002 and 2003 (and the examples that appear on the www.php.net for the ibase_blob_import) and nothing works in my case. 
MY table is UTF 8.

Althought the Interbase manual refers that:
"
Blob is the InterBase datatype that represents various objects, such as bitmapped images,
sound, video, and text. Before you store these items in the database, you create or
manage them as platform- or product-specific files or data structures, such as:
g TIFF, PICT, BMP, WMF, GEM, TARGA or other bitmapped or vector-graphic files.
g MIDI or WAV sound files.
g Audio Video Interleaved format (.AVI) or QuickTime video files.
g ASCII, MIF, DOC, RTF, WPx or other text files.
g CAD files.
You must load these files from memory into the database programmatically, as you do
any other host-language data items or records you intend to store in InterBase.
"

I tried with a BMP instead of TIF and the problem remains.
I suspect this is a bug in php. Can you help me?

Reproduce code:
---------------
      $="1";
      $ficheiro="d:\\y\\" .$i. ".tif";
      $fd = fopen($ficheiro, 'rb');
      if ($fd) {
         $blob = ibase_blob_import($fd);
         fclose($fd);
	    if (!is_string($blob)){
  		echo "Falhou a conversacao em BLOB da imagem ".$i.".tif<br>";
		exit;
		}else{
      		echo "BLOB ID da imagem (".$i.".tif): ".$blob."<br>";
		     } 	
 	 $ta = ibase_trans($transacao_ops, $connection);
       $query = "update ARQUIVO_DIGITAL set IMAGEM=? where NUMERO=".$i;
	 $prepared = ibase_prepare($ta, $query);
       if (!ibase_execute($prepared, $blob)) {
           // record insertion failed
		echo "Falhou a insercao da imagem na tabela ".$i.".tif<br>";
           ibase_rollback($ta);
           ibase_free_query($query);
           }else {
		       echo "Suceeso: ".$i."<br>";
                   ibase_commit($ta);
                   ibase_free_query($query);
			 }
        } else {
			echo "Falhou a abertura do ficheiro ".$i.".tif<br>";
               }	


Actual result:
--------------
PHP Warning:  ibase_execute() [<a href='function.ibase-execute'>function.ibase-execute</a>]: invalid BLOB ID  in D:\lixo.php on line xx


Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2007-12-25 16:10 UTC] kaf at p dot pt
The field in table is BLOB subtype 0. Not 1.
 [2009-06-08 10:34 UTC] lester at lsces dot co dot uk
Version 5.2.5 had a problem with blob_id. This has been fixed in later versions of PHP and should not now be a problem. We are reading and writing content with blob_id without any problems in 5.2.9.
 
PHP Copyright © 2001-2022 The PHP Group
All rights reserved.
Last updated: Fri Jul 01 13:03:42 2022 UTC