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
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If this is not your bug, you can add a comment by following this link.
If this is your bug, but you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: lars at strojny dot net
New email:
PHP Version: OS:

 

 [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

Add a Patch

Pull Requests

Add a Pull Request

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: Thu Mar 28 23:01:26 2024 UTC