header("Content-type:image/");
          //连接数据库 
$conn =@mssql_connect("localhost","sa","") or die("无法连接数据库服务器!");
//选择数据库
$db =@mssql_select_db("tb_news",$conn) or die("无法连接数据库!");
$sql="SELECT pic FROM news where id=277";
$result =@mssql_query($sql) or die("无法执行SQL:".$sql);
$row=mssql_fetch_array($result);
echo $row["binimage"];
以上代码保存为: pic.php
在需要调用的地方引用:
<img src="pic.php">