avirup Posted September 22, 2008 Share Posted September 22, 2008 <?php require_once("session_con.php"); require_once("functions.php"); confirm_logged_in(); //connect to the database server and the database dbconnect(); //session data fetching for test $id= $_SESSION['suid']; //echo $id; //Get data from the prevoius page //$id = $_GET['user_id']; //echo $id; //Checking the get data is valid or empty if(!$id) { echo "No image available"; } else { //Select image from the database $sql="SELECT * FROM `user_image` WHERE `user_id` ='".$id."';"; $result = mysql_query($sql) or die(mysql_error()); $row = mysql_fetch_array($result) or die(mysql_error()); $fdata = $row['FileData']; $ftype = $row['MimeType']; $fname = $row['FileName']; } //setting the header information to display the image header('Content-type: $ftype'); echo $fdata; ?> Omage is not displaying when i m running the page... save option is coming...instead of displaying the image... can anybody correct the code...coz...it's showing sometimes peculier data and last line is header output send already...thank You. Quote Link to comment Share on other sites More sharing options...
Garethp Posted September 22, 2008 Share Posted September 22, 2008 You need to do something like imagepng ($fdata); or imagegif($fdata); or something like that depending on what type of image it is Quote Link to comment Share on other sites More sharing options...
kpasiva Posted September 22, 2008 Share Posted September 22, 2008 The script used to set header and display image content, <?php //setting the header information to display the image header('Content-type: $ftype'); echo $fdata; ?> has to be moved to the else part because the error msg ("No image available") can't be displayed if session doesn't exist. Check the script by moving the above script to the else part whether it shows the error - "No image available". Quote Link to comment Share on other sites More sharing options...
avirup Posted September 22, 2008 Author Share Posted September 22, 2008 Thank for the reply..!!! Yea I have put the last part in the else part..session is exist and thus "No image " error is not echoing.Instead of that save the file dialog box is opening . when I save and open the file some peculiar data is showing there. So what I will do now!! Quote Link to comment Share on other sites More sharing options...
ranjuvs Posted September 22, 2008 Share Posted September 22, 2008 whats the value of $fdata? Quote Link to comment Share on other sites More sharing options...
avirup Posted September 22, 2008 Author Share Posted September 22, 2008 value?? it's the image file which I have store as a long blob....in Mysql... But when trying t fetch then showing a dialog box to save the file... When I am opening the file with the editor...then showing unknown data. Thank you... Quote Link to comment Share on other sites More sharing options...
avirup Posted September 22, 2008 Author Share Posted September 22, 2008 any one there to help me..please...!! Thank you..!!! Quote Link to comment Share on other sites More sharing options...
avirup Posted September 22, 2008 Author Share Posted September 22, 2008 I have done few changes in my code... as previously I was fetching the userid from the session now I wanna display the image linking from another page disaply.php <div id="photo"> <img src="getimage.php?user_id=<?php print $user_id; ?>" width="162" height="156" /></div> and now the getimage.php code <?php require_once("session_con.php"); require_once("functions.php"); confirm_logged_in(); //connect to the database server and the database dbconnect(); //Get data from the prevoius page $id = $_GET['user_id']; //I also tried echo to display the user_id...now its not coming also //Checking the get data is valid or empty if(!$id) { echo "Image is not available"; } else { //Select image from the database $sql="SELECT * FROM `user_image` WHERE `user_id` ='".$id."';"; $result = mysql_query($sql) or die(mysql_error()); $row = mysql_fetch_array($result) or die(mysql_error()); $fdata = $row['FileData']; $ftype = $row['MimeType']; $fname = $row['FileName']; //setting the header information to display the image header('Content-type: $ftype'); echo $fdata; } ?> Can anybody help me...now..please..!!! It's over a week I am trying...!!! Thank you..in advance!!! Quote Link to comment Share on other sites More sharing options...
FVxSF Posted September 22, 2008 Share Posted September 22, 2008 You said the image is stored in a BLOB? What's the encoding? Can you change it to BINARY? That's what's coming to my mind right now is the encoding. I could be wrong. Quote Link to comment Share on other sites More sharing options...
avirup Posted September 22, 2008 Author Share Posted September 22, 2008 Thanks for reply..!!! I save my image file as longblob and its in binary...!!! But still I am getting error...!!!! What can be the reason?? Quote Link to comment Share on other sites More sharing options...
FVxSF Posted September 22, 2008 Share Posted September 22, 2008 Ahhhh I think I know what it is. Take a close look at header('Content-type: $ftype'); you're tossing a variable in a set of single quotes. change the ' to " like this header("Content-type: $ftype"); Additionally you can also do this: header('Content-type: ' . $ftype); Quote Link to comment Share on other sites More sharing options...
avirup Posted September 22, 2008 Author Share Posted September 22, 2008 Thank you..but still... http://localhost/getimage.php is printed when i am running the file...!!!! As u said I changed the header to".... So now what??? Quote Link to comment Share on other sites More sharing options...
FVxSF Posted September 22, 2008 Share Posted September 22, 2008 Yeah, this is a weird problem you're having. One last thing I can think about is the mime type. What is the mime? image/jpeg image/png? can you add die( $row['MimeType'] ); After $fdata = $row['FileData']; $ftype = $row['MimeType']; $fname = $row['FileName']; And post what that says. The only, last thing I can think of then is an invalid mime type... And if you posted that link to show us what's going on we can't see it since it's on your localhost. Can you post an example on the web at all? Quote Link to comment Share on other sites More sharing options...
avirup Posted September 22, 2008 Author Share Posted September 22, 2008 as you said at ur last post I am sending the display as display1 Quote Link to comment Share on other sites More sharing options...
avirup Posted September 22, 2008 Author Share Posted September 22, 2008 My first post in this thread is opening file to save... I am sending this file http://rapidshare.com/files/147537199/getimage.php.html as this file is also peculier type.. Thank you very much for your time.. tell me anything what I should send u Quote Link to comment Share on other sites More sharing options...
FVxSF Posted September 22, 2008 Share Posted September 22, 2008 Ok, well I saw the screen http://www.imgx.org/public/view/full/11321 I see 10image/jpeg I don't know where the 10 came from but it should be just image/jpeg. check your database. for that entry. If you remove the 10 I think it should work. Quote Link to comment Share on other sites More sharing options...
avirup Posted September 22, 2008 Author Share Posted September 22, 2008 sorry 10 is the id no I am echoing..nothing else Quote Link to comment Share on other sites More sharing options...
FVxSF Posted September 22, 2008 Share Posted September 22, 2008 so you printed out just the mime? If so that 10 should not be there at all. Quote Link to comment Share on other sites More sharing options...
avirup Posted September 22, 2008 Author Share Posted September 22, 2008 No actually just for checking..it's nothing....!!! without that I have tried its only printing the images/jpeg Thank you Quote Link to comment Share on other sites More sharing options...
FVxSF Posted September 23, 2008 Share Posted September 23, 2008 Did you get it working yet then? Quote Link to comment Share on other sites More sharing options...
avirup Posted September 23, 2008 Author Share Posted September 23, 2008 No...I am still struggling.!!! I dont know...the code seeems ok...infact,...it worked soedays before,,...but now it is not working at all. Thank You....!!! Quote Link to comment Share on other sites More sharing options...
avirup Posted September 26, 2008 Author Share Posted September 26, 2008 can anybody help me about this?? Thank you.!!! Quote Link to comment Share on other sites More sharing options...
amagondes Posted September 26, 2008 Share Posted September 26, 2008 there really seems to be nothing wrong with your code. this may seem silly, but check that there is no whitespace outside of the php tags in your script image script and also session_con.php and functions.php Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.