|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #37421 mysql_bind_param() and BLOB-fields
Submitted: 2006-05-12 18:45 UTC Modified: 2006-05-13 05:06 UTC
From: lars at strojny dot net Assigned:
Status: Not a bug Package: MySQLi related
PHP Version: 5.1.4 OS: Linux
Private report: No CVE-ID: None
 [2006-05-12 18:45 UTC] lars at strojny dot net
Using mysqli in combination with the prepare-method and bind_param leads to troubles with the BLOB-field. I'm not really sure if it is a bug or I just thinking the wrong way.

Reproduce code:
$m = new mysqli( "host, "user", "pass" );
$m->select_db( "my_db" );
if( $statement = $m->prepare( "INSERT INTO my_table SET my_blob = ?" ))
   $file = file_get_contents( "image.png" );
   $statement->bind_param( 'b', $file );

Expected result:
Image should be inserted as binary data into the MySQL-table.

Actual result:
This does not work, it just puts zero bytes into the database. If I change $statement->bind_param( 'b', $file ); to $statement->bind_param( 's', $file ); it works as expected


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2006-05-13 05:06 UTC]
Thank you for taking the time to write to us, but this is not
a bug. Please double-check the documentation available at and the instructions on how to report
a bug at

Please check the sample at  how to handle blobs.
PHP Copyright © 2001-2023 The PHP Group
All rights reserved.
Last updated: Sun Dec 10 18:01:27 2023 UTC