Hey guys im having trouble getting the data i need out of my mysql table and i was hoping someone could help
Its an assignment for uni so im using some of the lecturers code, and just modifying it(so i apologize in advance for it being terribly messy). Anyway, the site is an online auction site. I have 4 rows for the images(the last 4 in the table) in my mysql table: imagedata(BLOB), imagename(Varchar(40)), imagesize(Varchar(40)), imagetype(Varchar(40)). All of which seem to receive the appropriate data when the file is submitted from the form. The problem is with viewing them, Here is the code i am using:
$sql = mysql_query("SELECT * FROM items2 WHERE description LIKE '%$_POST[keywords]%' AND categoryid = $_POST[categories] OR name LIKE '%$_POST[keywords]%' AND categoryid = $_POST[categories]"); //Search database for keywords
while ($row = mysql_fetch_array($sql, MYSQL_NUM)) {
$min = $row[4] + 1;
$output .= ("<hr><p> Item: <a href='item.php?uniqueid=$row[5]'>$row[0]</a> <br> Seller: $row[3] <br> Price: $$row[4]
<br>Image: <img src='getImage.php?id=$row[5]' $row[8] alt='$row[7]'></p>");
}
$end = ("</div>");
Here is getImage.php:
<?php
include'/export/student/s2681238/mysql/mysqlconfig.php';
include'/export/student/s2681238/mysql/mysqlconnect.php';
$id = $_GET['id'];
$query = "select imagedata, imagename, imagetype, imagesize " .
"from items2 where uniqueid = $id";
$result = @ mysql_query($query) or showerror();
$row = mysql_fetch_array($result);
$image = $row;
$data = $image['imagedata'];
$name = $image['imagename'];
$type = $image['imagetype'];
$size = strlen($data);
header("Content-length: $size");
header("Content-type: $type");
header("Content-Disposition: attachment; filename=$name");
?>
The Data that is stored in the table is as follows:
imagedata: blob 21.5kb
imagename: cap1.jpg
imagesize: width="200" height="194"
imagetype: image/jpeg
The Code results in an empty white box the size of the image i'm attempting to display. Ive got absolutely no idea whats wrong with it
Anyway its about 2Am here in Australia So im going to bed, hopefully ill have some good ideas by the morning
Cheers, Daniel