php.net |  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
Description:
------------
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:
---------------
<?php
$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 );
   $statement->execute();
}
?>

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

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2006-05-13 05:06 UTC] georg@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

Please check the sample at http://www.php.net/manual/en/function.mysqli-stmt-send-long-data.php  how to handle blobs.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Mon Nov 18 08:01:29 2024 UTC