这里是我使用的尝试,并从数据库中检索图像的代码:检索图像 - 不显示图像
<?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
我敢肯定的,我做的一切权利...不知道是怎么回事。帮助任何人?提前致谢!
摆脱那些邪恶的@标志!并删除最后一个结束标记:?> – 2012-04-19 03:24:14
这些mysql函数名称区分大小写,什么/谁给你的想法,你可以大写他们,抑制错误也是crackers当你试图调试..也'$ id'是空白所以它永远不会那么远,你应该使用'isset($ id)&& is_numeric($ id)'来代替。 – 2012-04-19 03:26:22
@LawrenceCherone在php中的函数名称*不区分大小写,但我仍然认为他们应该像他们一样对待。 – 2012-04-19 03:32:58