// get the image from the db
$sql = "SELECT bild, OCTET_LENGTH(bild) AS imagesize FROM produkt WHERE id=$_GET[id]";
// the result of the query
$result = mysql_query("$sql") or die("Invalid query: " . mysql_error());
$row = mysql_fetch_array($result);
if($row['imagesize'] == 0)
{
header("Content-type: image/jpeg");
echo file_get_contents("Images/images/produkter/ingen_bild.jpg");
}
else{
// set the header for the image
header("Content-type: image/jpeg");
echo $row['bild'];
}
Frågan#1
Hallå. har denna kod:
// get the image from the db
$sql = "SELECT bild, OCTET_LENGTH(bild) FROM produkt WHERE id=$_GET[id]";
// the result of the query
$result = mysql_query("$sql") or die("Invalid query: " . mysql_error());
if($result['OCTET_LENGTH(bild)'] == 0)
{
header("Content-type: image/jpeg");
echo file_get_contents("Images/images/produkter/ingen_bild.jpg");
}
else{
// set the header for the image
header("Content-type: image/jpeg");
echo mysql_result($result, 0);
}
Så, nu har jag ändrat koden lite, men jag fått att IF satsen alltid blir true nu, alltså.. den fattar inte när det finns en bild.
Detta är ganska akut, har deadlie idag
// Hampus