|
Posted by Paul on 11/04/05 17:14
Hi,
I've created a very simple SQL database called images (really simple -
has 3 columns - id (primary key, smallint(6)), description
(varchar(127)) and image (longblob) for the image.
Using phpmyadmin, I've uploaded an image to the database and it's all
fine.
Next, created a webpage which calls a php script to render the file.
Only problem is that all that happens is the html is rendered and a few
seconds later, I get an error "The URL is not valid and cannot be
loaded".
The page looks like this
<html>
<head>
<title>Thumbnail tester</title>
</head>
<body bgcolor="#000">
<p style="text-align:center; font-size:2.0em; color:white">BE AFRAID</p>
<div align="center">
<img src="thumbnail.php?id=1" alt="A picture" />
</div>
</body>
</html>
The php is
<?php
$id=_POST['id'];
header("Content-type: image/jpeg");
$db = mysql_connect("localhost", "paul", "my_password_not_yours!");
mysql_select_db("testbase", $db);
$query = "select image from images where id=$id";
$result = mysql_query($query, $db);
$row = mysql_fetch_array($result);
$jpg = $row["image"];
echo $jpg;
?>
Any ideas where I'm going wrong?
TTFN
Paul
P.S. Yes, there is a good reason for me doing this and yes, I have done
the mandatory 35 minutes googling for an answer...
--
"Logic, my dear Zoe, is merely the ability to be wrong with authority" -
Dr Who
Navigation:
[Reply to this message]
|