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. Link to comment https://forums.phpfreaks.com/topic/125267-image-is-not-displaying/ 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 Link to comment https://forums.phpfreaks.com/topic/125267-image-is-not-displaying/#findComment-647542 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". Link to comment https://forums.phpfreaks.com/topic/125267-image-is-not-displaying/#findComment-647549 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!! Link to comment https://forums.phpfreaks.com/topic/125267-image-is-not-displaying/#findComment-647582 Share on other sites More sharing options...
ranjuvs Posted September 22, 2008 Share Posted September 22, 2008 whats the value of $fdata? Link to comment https://forums.phpfreaks.com/topic/125267-image-is-not-displaying/#findComment-647592 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... Link to comment https://forums.phpfreaks.com/topic/125267-image-is-not-displaying/#findComment-647716 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..!!! Link to comment https://forums.phpfreaks.com/topic/125267-image-is-not-displaying/#findComment-647931 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!!! Link to comment https://forums.phpfreaks.com/topic/125267-image-is-not-displaying/#findComment-647966 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. Link to comment https://forums.phpfreaks.com/topic/125267-image-is-not-displaying/#findComment-647992 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?? Link to comment https://forums.phpfreaks.com/topic/125267-image-is-not-displaying/#findComment-648033 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); Link to comment https://forums.phpfreaks.com/topic/125267-image-is-not-displaying/#findComment-648060 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??? Link to comment https://forums.phpfreaks.com/topic/125267-image-is-not-displaying/#findComment-648078 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? Link to comment https://forums.phpfreaks.com/topic/125267-image-is-not-displaying/#findComment-648098 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 Link to comment https://forums.phpfreaks.com/topic/125267-image-is-not-displaying/#findComment-648123 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 Link to comment https://forums.phpfreaks.com/topic/125267-image-is-not-displaying/#findComment-648129 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. Link to comment https://forums.phpfreaks.com/topic/125267-image-is-not-displaying/#findComment-648134 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 Link to comment https://forums.phpfreaks.com/topic/125267-image-is-not-displaying/#findComment-648141 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. Link to comment https://forums.phpfreaks.com/topic/125267-image-is-not-displaying/#findComment-648143 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 Link to comment https://forums.phpfreaks.com/topic/125267-image-is-not-displaying/#findComment-648149 Share on other sites More sharing options...
FVxSF Posted September 23, 2008 Share Posted September 23, 2008 Did you get it working yet then? Link to comment https://forums.phpfreaks.com/topic/125267-image-is-not-displaying/#findComment-648271 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....!!! Link to comment https://forums.phpfreaks.com/topic/125267-image-is-not-displaying/#findComment-648610 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.!!! Link to comment https://forums.phpfreaks.com/topic/125267-image-is-not-displaying/#findComment-651562 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 Link to comment https://forums.phpfreaks.com/topic/125267-image-is-not-displaying/#findComment-651610 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.