这是我用来尝试从数据库中检索图像的代码:
<?php
if($id)
{
//please change the server name username and password according to your mysql server setting
$mysql_server="localhost";
$mysql_username="myuser";
$mysql_password="mypass";
$mysql_database="mydb";
//connect to database using above settings
@MYSQL_CONNECT("localhost",$mysql_username,$mysql_password);
@mysql_select_db("mydb");
//select the picture using the id
$query = "select bin_data,filetype from todo where id=$id";
//execute the query
$result = @MYSQL_QUERY($query);
//get the picture data which will be binary
$data = @MYSQL_RESULT($result,0,"bin_data");
//get the picture type. It will change according to file extension it may be either gif or jpg
$type = @MYSQL_RESULT($result,0,"filetype");
//send the header of the picture we are going to send
Header( "Content-type: $type");
//send the binary data
echo $data;
};
?>
它不显示请求的图像,而是显示这个图标:(不知道你怎么称呼它)... http://i.imgur.com/bo6Jg.png
这是我表中的所有列:http: //i.imgur.com/PuWvl.png
我很肯定我做的一切都是正确的……不知道发生了什么。帮助任何人?提前致谢!