Member Avatar for jpknoob

Hi, I have managed to upload images to a table in mysql, however, i am having problems with displaying the image, all i get is a box with a red cross in it and i'm not sure what i'm doing wrong.

Here is the code i am using to view the image;

<?php
require_once ('connect.php');

$make = $_GET['make'];

if(!isset($make) ¦¦ empty($make)){
die("There is no image available");
}

else{
$quert = mysql_query("select image from photo where make=$make");
$row = mysql_fetch_array($query);
$content = $row['image'];

header('Content-type: image/jpg');
echo $content;

}
?>

The previous file is selecting distinct(make) from 2 tables and returning values. The $row[make] is then sent through to the above code to display the jpeg.

Can anyone help?

Recommended Answers

All 5 Replies

Member Avatar for jpknoob

If this is your actual code then $quert should be $query

Sorry, that was just an error when i was writing out the code, it is written correctly in my file...

Did you try the query in phpmyadmin ? Perhaps the missing single quotes trigger an error. Another reason could be that the query returns no result.

Member Avatar for jpknoob

Figured it out!!
I put the single quotes round $make and changed the content type from image/jpg to image/jpeg, works fine, thanks.

Thanks for the feedback, totally overlooked the content type. Please mark this thread solved.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.