/    Sign up×
Community /Pin to ProfileBookmark

help me display image from my database..

can anyone help me display my image coming from my database.. the datatype of the image being uploaded is “image”.. I already tried some code base on my research but I only get a broken image or just the raw data coming from the database..

>

Here is the code i used in displaying my image..

$sql = “SELECT StudentPicture from dbo.ES_Students where StudentNo = ‘2009100496’”;
$stmt = sqlsrv_query( $conn, $sql );
if( $stmt === false) {
die( print_r( sqlsrv_errors(), true) );
}

while( $row = sqlsrv_fetch_array( $stmt, SQLSRV_FETCH_ASSOC) ) {
echo “<br/>”;

$img = $row[‘StudentPicture’];
header(‘Content-Type: image/jpeg’);
echo $img;

the output of that code is a broken image/invalid image icon..
thanks in advance for your reply ?

to post a comment
PHP

2 Comments(s)

Copy linkTweet thisAlerts:
@WestWebAug 30.2012 — Are you just storing the path to the image in the database, and not the images themselves?

Hopefully yes, and if so, check that the src attribute of your image tag is properly pointing to where the image file is stored on your server.
Copy linkTweet thisAlerts:
@arronleeOct 25.2013 — [COLOR="#000000"]Hi, I am a newbie here. I wonder whether it can be solved by[/COLOR] [COLOR="#000000"]creating a windows image viewer[/COLOR][COLOR="#000000"]? I am almost agreen hand on this problem. But I hope yousuccess. Good luck.







Best regards,

Arron[/COLOR]
×

Success!

Help @luckycabarlo spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.17,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...