I have found a lot of posts that describe the same problem, but everything I tried failed. For a profile page I am making people can upload 4 pictures. When no picture is available I want to show a default picture. My complete code is like this now:
$id = $_GET['ID'];
$link = mysql_connect("xxx", "xxx", "xxx");
mysql_select_db("xxx");
$sql = "SELECT * FROM profielen WHERE ID = $id";
$result = mysql_query("$sql");
$row = mysql_fetch_assoc($result);
mysql_close($link);
header("Content-type: image/jpeg");
if ($row['Foto4'] == NULL){
//echo '<img src="/img/noImage.jpg" />';
echo $row['Foto5'];
}
else {
echo $row['Foto4'];
}
In this form the code works, so I know that the if-statement is correct. When I try to uncomment the commented line, it shows a broken link as the image.
I have tried with double quotes and then escape the double quotes within the img tag. I have also tried to call it as a variable and without a / before the img-path. And also just tried to say echo "No image", but it seems that if I do anything else than echo $row[x] it just does not work. When I try to display the image in HTML it works fine, so the name of the file is correct.
I am running out of ideas, so maybe someone can help?
Foto5andFoto4contain?