php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #34022 prepared statement using blobs doesnt function
Submitted: 2005-08-07 00:54 UTC Modified: 2005-08-07 19:28 UTC
Votes:1
Avg. Score:4.0 ± 0.0
Reproduced:1 of 1 (100.0%)
Same Version:1 (100.0%)
Same OS:1 (100.0%)
From: mike dot norton at ultisearch dot co dot uk Assigned:
Status: Closed Package: MySQLi related
PHP Version: 5.0.4 OS: Fedora Core 3
Private report: No CVE-ID: None
 [2005-08-07 00:54 UTC] mike dot norton at ultisearch dot co dot uk
Description:
------------
When using mysql with bind_params on blob data only the first 4 bytes of data get included.




Reproduce code:
---------------
<?php
  $mysqli = new mysqli("localhost", "user", "pass", "db");
 /* check connection */
 if (mysqli_connect_errno()) {
  printf("Connect failed: %s\n", mysqli_connect_error());
  exit();
 }
 $filename = "/path_to/files/5_copy14.jpg";
 /* create a prepared statement */
 $stmt =  $mysqli->stmt_init();
 $stmt->prepare("insert into user_image (image) values (?)");
 $data = fread(fopen($filename, "rb"), filesize($filename));
 $stmt->bind_param('b',$data);       /* Prove that the $data variable contains the correct data */
 print $data;
 $stmt->execute();
 $stmt->close();
 $mysqli->close();
?>

Expected result:
----------------
Image is displayed and image data is inserted into database 

Actual result:
--------------
First 4K of image is inserted into database rest seems to be discarded

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2005-08-07 19:28 UTC] mike dot norton at ultisearch dot co dot uk
Seems to work with that function correctly
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Fri Mar 29 15:01:28 2024 UTC