By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
438,216 Members | 1,032 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 438,216 IT Pros & Developers. It's quick & easy.

img display from mysql database needs help

tolkienarda
100+
P: 316
hi all

I have this script that i found and modified slightly it appears to use some code i am not famalier with so trouble shooting has turned into a night mare but here is what i have

this part is on my page where i want the image displayed
[HTML]
<img src="imagedisp.php?title=asdf">
[/HTML]

here is the imagedisp.php page

[PHP]

$result = "SELECT imgdata, type FROM pix WHERE title='$title'";
$Show = mysql ( $hDB, $hSQL );
$rows = mysql_num_rows($hShow);

if($rows<1){
// no image matches this query
}
else{
// at least one image has this title
$getPhoto = mysql_fetch_object($Show);

// we need to determine the mime type
$Type = $getPhoto->type;

// and send the correct header to the browser
Header("Content-type: $Type");

// now send the image
$Body = $getPhoto->body;
echo $Body;
flush();
}
[/PHP]

thanks for any guidence

eric
Feb 15 '07 #1
Share this Question
Share on Google+
3 Replies


cassbiz
100+
P: 202
hi all

I have this script that i found and modified slightly it appears to use some code i am not famalier with so trouble shooting has turned into a night mare but here is what i have

this part is on my page where i want the image displayed
[HTML]
<img src="imagedisp.php?title=asdf">
[/HTML]

here is the imagedisp.php page

[PHP]

$result = "SELECT imgdata, type FROM pix WHERE title='$title'";
$Show = mysql ( $hDB, $hSQL );
$rows = mysql_num_rows($hShow);

if($rows<1){
// no image matches this query
}
else{
// at least one image has this title
$getPhoto = mysql_fetch_object($Show);

// we need to determine the mime type
$Type = $getPhoto->type;

// and send the correct header to the browser
Header("Content-type: $Type");

// now send the image
$Body = $getPhoto->body;
echo $Body;
flush();
}
[/PHP]

thanks for any guidence

eric
Shooting in the dark here, but hope it helps,

Expand|Select|Wrap|Line Numbers
  1. <img src="<?php include=imagedisp.php?title=asdf ?>" />
  2.  
you have to be sure that the output is still an image (jpg, gif, png, etc...)
Feb 15 '07 #2

cassbiz
100+
P: 202
oops wrote the include statement wrong.

Expand|Select|Wrap|Line Numbers
  1. <img src="<?php include imagedisp.php?title=asdf; ?>" />
  2.  
Feb 15 '07 #3

tolkienarda
100+
P: 316
oops wrote the include statement wrong.

Expand|Select|Wrap|Line Numbers
  1. <img src="<?php include imagedisp.php?title=asdf; ?>" />
  2.  
thanks i will give it a shot and get back to you if it works or not

eirc
Feb 16 '07 #4

Post your reply

Sign in to post your reply or Sign up for a free account.