Author Topic: Help with blobs  (Read 501 times)

Offline Zeggy

  • Global Moderator
  • Level 35
  • *****
  • Posts: 1,187
  • Reputation: +13/-4
    • View Profile
Help with blobs
« on: November 09, 2008, 03:30:20 PM »
I'm trying to use mysqli to fetch a single column from a row.

Here's the code I'm using:

Code: [Select]
<?php
include('config.php');

$stmt $db->prepare('select `data` from `wallpapers` limit 1');
$stmt->execute();
$stmt->store_result();
$stmt->bind_result($img);

$stmt->fetch();

//header( "Content-type: image/jpg");
var_dump($img);
?>

The column `data` is a longblob. But the output is always: string(0) ""

Is there a special way of retrieving blob data? If I try to retrieve any other column, it works fine. But not the data column.

EDIT: Okay, I found the problem... When storing the blob data in the database with mysqli, the type of the blob data was 'b'. Apparently that doesn't work. I changed it into string type ('s') and now it works fine. So it wasn't a problem with retrieving the data, but inserting the data.

EDIT again: And now I found out why it didn't work :) So if you're wondering, if you want to send blob type data, you need to use the send_long_data function - http://uk2.php.net/manual/en/mysqli-stmt.send-long-data.php
I tried it again and now it's fine.
« Last Edit: November 09, 2008, 03:57:32 PM by Zeggy »

 


SimplePortal 2.3.3 © 2008-2010, SimplePortal