blob不存在时的自定义图像(404)[重复]

This question already has an answer here:

I have a php page that has blobs from my database

i need 404 image to display when there is no blob

https://i.imgur.com/gp0Q2kQ.jpg https://i.imgur.com/XgGDExK.jpg

<?php
$host = "localhost";
$username = "root";
$password = "12345678";
$db = "sis";
$PicNum = $_GET["PicNum"];

mysql_connect($host,$username,$password) or die("Impossível conectar ao banco."); 
@mysql_select_db($db) or die("Impossível conectar ao banco."); 
$result=mysql_query("SELECT * FROM usuarios WHERE id=$PicNum") or die("Impossível executar a query "); 
$row=mysql_fetch_object($result); 

Header("Content-type: image/gif"); 
echo $row->avatar;?>
</div>

Check the blob column is empty or NULL on the query.


$result = mysql_query("SELECT * FROM usuarios WHERE id=$PicNum AND WHERE length(avatar) != 0 AND avatar IS NOT NULL") or die("Impossível executar a query "); 
$row=mysql_fetch_object($result); 

if($row)
  echo $row->avatar;
else 
  {
    // return 404 page or print as 404 error
    "<h1>404 Not Found</h1>"; 
    echo "The page that you have requested could not be found."; 
  }

?>