Hi All!

I am working with an MSSQL DB which stores images as blob's. When I pull out the blob it seems to be cut off at a fixed length. Every image only displays the top 1/3 or so.

My query is very basic and has no limitations in it for size. Is the information in the DB cut-off? Or do I need to do something inside my query to process a large blob? I'm using ODBC through PHP.

Thank you in advance for ANY help you might be able to offer!

$sqlquery="SELECT image AS theimage FROM IDX_IMAGES_FULL WHERE id='1234'";

 $process=odbc_exec($sqlconnect, $sqlquery);
 $row=odbc_fetch_array($process);
                                    
 $img = odbc_result($process,'theimage');
 $img = $row['theimage'];
 print $img;

This is a PHP question, not MSSQL question. If you store the data properly and retrieve the data properly with PHP then its all good.

You can use

Select DataLength(image) As Sz
From Table

To verify you have the complete image. If the file sizes match then its your PHP that is bad.

Thank you for the DataLength() tip.

The DB is not my own, and I have no control over the content, I can only pull it out.

You are right, DataLength returns the full size of the image, but what is actually getting displayed in the browser is being capped at 4.0Kb on the nose.

I thought this was a problem with my DB query, but you think it's a problem with the PHP? Somewhere the data is getting limited to 4k - ideas?

This is the first time using a blob field.

Probably. I use blob in MSSQL all the time with no problems. Unfortunately I have no PHP experience so you may try the PHP forum :P

If you have any more database questions then go ahead and post back here

Please mark this thread as solved if you feel we have answered the MSSQL end of this question and good luck!

Ok - I've been working on this for the last 20 hours and finally got it solved.

I was going through php.ini settings, odbc functions, and buffering settings endlessly - BUT it came down to a DB query.

Before running the SELECT statement I added

odbc_exec($sqlconnect, "set textsize 65536");

I guess this sets the field size for the Session. I don't really understand why a huge field like the blob would end up being trimmed to 4096 on output - but at this point I'm just glad it's working.

Solved!

commented: I bet this one sucked to debug :P Good job though +9
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.