alena1347 Posted February 8, 2013 Share Posted February 8, 2013 I have stored a image in database as it is small dd not upload in folder it got uploade and is shown in database i stored it with using $imgData =addslashes (file_get_contents($_FILES['image']['tmp_name'])); then a insert query with $imgData Now when i retrive it with select query from database and display <td rowspan="12"><?php header('Content-type:image/jpg'); $img=stripslashes($info['image']); echo $img; ?></td> it shows The image "localhost/final/../f.php?action="view&id=53" cannot be displayed because it contains errors Quote Link to comment Share on other sites More sharing options...
PFMaBiSmAd Posted February 8, 2013 Share Posted February 8, 2013 Each image you put onto a web page requires its own <img src='url_of_an_image' alt=''> HTML tag. The url_of_an_image for an image that is dynamically output by php must be to a .php script that outputs the correct content type header followed by the image data. Since you would want to use the same .php file for all your dynamically output images, you would want to put an GET parameter on the end of the url that indicates the id of the image. If you search the Internet/forum, you should be able to find example code showing how to do this. Quote Link to comment Share on other sites More sharing options...
DaveyK Posted February 8, 2013 Share Posted February 8, 2013 From php.net: "Remember that header() must be called before any actual output is sent, either by normal HTML tags, blank lines in a file, or from PHP. It is a very common error to read code with include, or require, functions, or another file access function, and have spaces or empty lines that are output before header() is called. The same problem exists when using a single PHP/HTML file." The header() is probably causing your first problem. 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.