homepage Welcome to WebmasterWorld Guest from
register, free tools, login, search, pro membership, help, library, announcements, recent posts, open posts,
Pubcon Platinum Sponsor 2014
Visit PubCon.com
Home / Forums Index / Code, Content, and Presentation / Databases
Forum Library, Charter, Moderators: physics

Databases Forum

Display Images Stored in MSSQL database (using PHP)
Really stuck - need help!

 3:08 pm on Oct 11, 2009 (gmt 0)

I'm pulling my hair out in frustration at this little bit of php code that I thought would work - yet doesn't. It's meant to take an image ("image" datatype) from a MSSQL (not MySQL) database and display it.

Oddly enough when the url of the script is visted the title bar states "JPEG Image, 1024x768 pixels" (Firefox) which is spot on - yet all that appears is a completely blank/white image (1024x768 pixels, but only 4.00 KB in size).

Is there something wrong with the script?

$myUser = "sa";
$myPass = "#*$!#*$!X";
$myDB = "YYYYY";

$dbhandle = mssql_connect($myServer, $myUser, $myPass, true) or die("Error1");
$selected = mssql_select_db($myDB, $dbhandle) or die("Error2");
$query = "SELECT image FROM abc WHERE id=999";
$result = mssql_query($query,$dbhandle);

$content=mssql_result($result, 0, "image");
header('Content-type: image/jpeg');
echo $content;



 6:16 pm on Oct 11, 2009 (gmt 0)

Please ignore the last post - the problem was due to the mssql.textlimit and mssql.textsize settings in php.ini (they default to 4096 hence only a small part of the image was actually being extracted from the database.

Global Options:
 top home search open messages active posts  

Home / Forums Index / Code, Content, and Presentation / Databases
rss feed

All trademarks and copyrights held by respective owners. Member comments are owned by the poster.
Home ¦ Free Tools ¦ Terms of Service ¦ Privacy Policy ¦ Report Problem ¦ About ¦ Library ¦ Newsletter
WebmasterWorld is a Developer Shed Community owned by Jim Boykin.
© Webmaster World 1996-2014 all rights reserved