PHP从MySQL中读Gif图片数据时出现乱码,请指教错误原因 (output started at F:\software\PHP\display.php:5) in F:\software\PHP\display.php on line 10 问题已经很清楚了,display.php第5行处有输出,请贴出display.php前5行的代码 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 对不起,显示的脚本忘记贴了:<?php /* 连接选择数据库 */ $link = mysql_connect("localhost", "root", "") or die("Could not connect : " . mysql_error()); print "Connected successfully"; mysql_select_db("binary_data") or die("Could not select database"); $query="select bin_data from binary_data where id=2"; $result=@MYSQL_QUERY($query); $data=@MYSQL_RESULT($result,0,"bin_data"); header ("Content-type: image/gif"); echo $data; mysql_close($link);?> 我将 // header ("Content-type: image/gif");注释掉,没有了错误提示,但输出仍是乱码,显示如下Connected successfullyGIF89a––ÔÿÿÿÌÿÿÿÌÿÿÌÌÌÌÌÌ™Ìÿ™Ìÿ™™Ì™™Ìf™ÌfÌ™f™™™™™™f那么,是不是用echo语句输出的只是二进制流呢?需要<img src=" ">之类的语句吗?<?php /* 连接选择数据库 */ $link = mysql_connect("localhost","root", "") or die("Could not connect : " . mysql_error()); print "Connected successfully"; mysql_select_db("binary_data") or die("Could not select database"); $query="select bin_data from binary_data where id=2"; $result=@MYSQL_QUERY($query); $data=@MYSQL_RESULT($result,0,"bin_data"); // header ("Content-type: image/gif"); echo $data; mysql_close($link);?> 把print "Connected successfully";去掉,这个串不是图片内容,若作为图片解释自然就是乱码了header ("Content-type: image/gif");这个头还是要的,他通知浏览器将要传送的数据是什么类型的 SQL错误:You have an error in your SQL syntax;急求帮助,万分感谢。 关于FCK 编辑器默认字体大小的问题 用的APMServ5.2.6为什么不好用 cms扩展模型关于如下储值方式 求一个js正则 怎么用php获取远程网页的指定代码?最好能共享对方的cookies~ php常量轉化為對象 PHP 的并行如何实现? 大家介绍基本关于php的英文版参考书吧 我的数据库不能写入,为什么??? php调用java api问题! 请各位指点,PHP找工作要往哪些地方奔
<?php
/* 连接选择数据库 */
$link = mysql_connect("localhost", "root", "")
or die("Could not connect : " . mysql_error());
print "Connected successfully";
mysql_select_db("binary_data") or die("Could not select database");
$query="select bin_data from binary_data where id=2";
$result=@MYSQL_QUERY($query);
$data=@MYSQL_RESULT($result,0,"bin_data");
header ("Content-type: image/gif");
echo $data;
mysql_close($link);
?>
注释掉,没有了错误提示,但输出仍是乱码,显示如下Connected successfullyGIF89a––ÔÿÿÿÌÿÿÿÌÿÿÌÌÌÌÌÌ™Ìÿ™Ìÿ™™Ì™™Ìf™ÌfÌ™f™™™™™™f
那么,是不是用echo语句输出的只是二进制流呢?需要<img src=" ">之类的语句吗?<?php
/* 连接选择数据库 */
$link = mysql_connect("localhost","root", "")
or die("Could not connect : " . mysql_error());
print "Connected successfully";
mysql_select_db("binary_data") or die("Could not select database");
$query="select bin_data from binary_data where id=2";
$result=@MYSQL_QUERY($query);
$data=@MYSQL_RESULT($result,0,"bin_data");
// header ("Content-type: image/gif");
echo $data;
mysql_close($link);
?>
header ("Content-type: image/gif");
这个头还是要的,他通知浏览器将要传送的数据是什么类型的