Reputation: 1400
So i have this code in the HTML:
<img src="imagescript.php?id=1">
And i have this code in the imagescript.php :
<?php
$servername="localhost";
$username="root";
$conn= mysql_connect($servername,$username)or die(mysql_error());
mysql_select_db("licitatii",$conn);
$sql="select picture from auctions where auction_id='$_GET[id]'";
$result=mysql_query($sql,$conn) or die(mysql_error());
$row = mysql_fetch_assoc($result);
$image = $row['picture'];
header("Content-type: image/jpeg");
print $image;
?>
I have used this from instructions on the internet but my image doesn't display .
Is it possible that I have incorrectly uploaded the image?
I used < input name="regphoto" type="file" > in a method="POST" form and then inserted in the table the $_POST[regphoto]
If it helps you, here's the php script i used to insert the photo after clicking the submit button:
$sql="insert into auctions (auction_id
,owner_id
,parent_category_id
,title
,description
,picture
,postage
,starting_price
,buyout_price
,end_date
)values(NULL,'$ownerid','$parentcategoryid','$_POST[regtitle]','$_POST[regdescription]','$_POST[regphoto]','$_POST[regpostage]','$_POST[regstartingprice]','$_POST[regbuyoutprice]','$expiration')";
As u can see, I inserted into the "picture" column(type mediumblob) the value $_POST[regphoto]
Upvotes: 0
Views: 1832
Reputation: 91762
A few comments that might help:
$id = (int) $_GET[id]
and use $id
in your query.$_POST[photo]
sounds wrong: You need $_FILES['photo']
and that is an array, see the manual.Upvotes: 1