Access BLOB

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Carolyn Longfoot

    #1

    Access BLOB

    Help! This is driving me crazy...

    I'm trying to read a BLOB from a db and display it in a browser, like
    so:
    $query="SELECT blob from table where blob_id=9";
    $result=mysql_q uery($query);
    $blob=mysql_fet ch_assoc($resul t);

    Now when I do
    print_r (array_values($ blob));

    I get
    Array ( [0] => ÿØÿàJFIF...
    which is as it should be. Would this not tell me I can also do
    print ("$blob[0]");

    If yes (since I get [0] with array_values), then why do I get
    Notice: Undefined offset: 0

    And, of course, how do I access $blob to get at the data? For
    imagecreatefrom string for example...


    Thanks a lot,
    Caro
  • Tom Thackrey

    #2
    Re: Access BLOB


    On 23-Jan-2004, c_longfoot@hotm ail.com (Carolyn Longfoot) wrote:
    [color=blue]
    > Help! This is driving me crazy...
    >
    > I'm trying to read a BLOB from a db and display it in a browser, like
    > so:
    > $query="SELECT blob from table where blob_id=9";
    > $result=mysql_q uery($query);
    > $blob=mysql_fet ch_assoc($resul t);
    >
    > Now when I do
    > print_r (array_values($ blob));
    >
    > I get
    > Array ( [0] => ÿØÿàJFIF...
    > which is as it should be. Would this not tell me I can also do
    > print ("$blob[0]");
    >
    > If yes (since I get [0] with array_values), then why do I get
    > Notice: Undefined offset: 0
    >
    > And, of course, how do I access $blob to get at the data? For
    > imagecreatefrom string for example...[/color]

    You pretty much have to reverse whatever process you used to create the blob
    you stored in the table.

    blob by definition has no implied data structure.

    Did you serialize an object to create the blob, then unserialize it.
    Did you put the contents of an image file in the blob, then treat it as
    such.


    --
    Tom Thackrey

    tom (at) creative (dash) light (dot) com
    do NOT send email to jamesbutler@wil lglen.net (it's reserved for spammers)

    Comment

    • Carolyn Longfoot

      #3
      Re: Access BLOB

      AHHHH!! Stupid stupid stupid.

      All I needed to do was
      imagecreatefrom string($blob[blob])


      Thanks for getting me to think!

      Caro

      Comment

      Working...