图片为何显示出是乱码? <meta http-equiv="Content-Type" content="text/html; charset=gb2312">这行删了试试 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 要用img显示,不能直接echo如:<img src="<?php 这里怎么填你再去找找,我以前做asp的,php的我还不懂?>" width="568" height="282"> 说点个人看法:echo 可以输出二进制流的图片。没有问题。img那种是图片 “文件”。在php中一般都是imagepng()什么的生成的用这个(我也是刚学,大大们指导指导。先谢谢了。不要吝啬哦:)) 给你个例子看看先,注意要输出正确的MIME header$query = "SELECT pic FROM tablename WHERE id = $id"; if (!($result = @ mysql_query ($query,$connection))) showerror(); $data = @ mysql_fetch_array($result); if (!empty($data["pic"])) { // Output the GIF MIME header header("Content-Type: image/gif"); // Output the image echo $data["pic"]; } 看看我的图片怎么显示的,其实只要是读出来就可以用<imag src>来输出现成的图像<?/******************************************************* author:xiog xiangzhong** date: 2004.3.31** function:对考试管理页面的主页面******************************************************/ include_once("test/UserTestDisplay.php"); $db = New NewUserTestClass(); $userid="xiong"; $dd=new Odbc(); $sql="select top 1 * from user_test where userid='".$userid."' order by testdate desc"; $dd->Query($sql); if($rs=$dd->NextRecord()) $date=date("Y-m-d",$rs['testdate']);?><html><head><meta http-equiv="Content-Type" content="text/html; charset=gb2312"><link rel="stylesheet" href="../css/css.css"><title>Qualification Mangement</title></head><body bgcolor="#E8E8E8" ><table width="100%" border="0" cellspacing="0" cellpadding="0"> <tr bgcolor="#336699"> <td class="PTitle" align="left">Test</td> </tr> <tr><td> </td></tr></table><form name=form1 method='post' action=<?=$PHP_SELF?> ><table width="100%" border="0" cellspacing="0" cellpadding="0"> <tr><td> <table> <tr><td>Welcome <?=$userid?> coming Test.<br>Your Previous came at <?=$date?> </table> </td></tr> <tr><td> <table id=table4 > <tr><td> <? include_once("include/gd_class2.php"); $db=New NewUserTestClass(); $db->Select("userid",$userid,"="); $i=0; while($result=$db->fetch()) { echo $rs[$i][0]=$result['scores']; echo " "; echo $testid=$result['testid']; echo " "; echo $date[$i]=$result['testdate']; echo " "; $i++; } $cnt=$i; echo $cnt."<br>"; for($i=0;$i<$cnt;$i++){ echo $rs[$i]."<br>"; } if(!isset($trans)){ $trans=1;} $report=new DrawImageReportClass(); //function SetImage($x,$y,$r,$g,$b,$tran) $report->SetImage(500,300,255,255,255,0);//参数(长,宽,背影色R,G,B,是否透明1或0) //function SetFont($size,$color) $report->SetFont(1);//字体大小1-10 //$rs= array(0=> array("a","b","c","d"),1=> array("d","c","b","d"),2=> array("c","e","c"),3=>array("c","a","d"));//数值,用指定符号隔开 // $rs= array(0=> array(100,250),1=> array(450,400),2=> array(300,200));//数值,用指定符号隔开 //$case1 =array("a","b","c"); $case = array("my","Your","she"); //$rsx=array("question1","quetion2","qutstion3","question4","question5","question6"); //$rsx= array(1,2,3,4,5,6); $rsy= array(20,40,60,80,100); //$rsy= array("a","b","c","d","e"); $colors = array("FF0000","FFFF00","00FFFF","DDBBCC"); $report->SetRecords($rs,$testid,$rsy,$date,$colors,$trans,20); //$report->SetRecords($rs,$user,$rsy,$rsx,$colors,1,20); //参数(分隔数值的指定符号,数值变量,样式1为竖柱图2为横柱图3为折线图,距离) $report->DrawReport(); header('Content-type: image/png'); echo "<img src='".$report->mShow.$report->mName."'>"; ?> </td></tr> </table> </td></tr> <TR><TD align=center> <input type=button value="New Test" onclick=add()> </TD></TR> <tr bgcolor="#336699"><td> </td></tr></table></form></body></html> 支持楼上的uuq,我也碰到同样的问题,单独写一些简单的代码能把图片从数据库显示出来,但是我把代码嵌入到论坛文件中,显示出来的就是乱码,请问怎样把图片从数据库输入到文件中,然后用路径显示出来,能不能给点代码啊! 正则表达式中的“\”转义的问题 phpExcelReader导入问题 ajax做级联下拉列表在修改数据时如何默认选择某一项呢? 倒序遍历文件夹问题 preg_replace 匹配网址和邮箱 并且替换成为 链接 的代码 在网上搜索不到 希望大家提供一下 有朋友能发一个最新的支付宝支付的PHP范例么? 大家都用的是什么编译环境? 请问兄弟们有 ajax+PHP+mysql的源码或例子看看吗? SmartTemplate模板嵌套问题 出错了??? cookie还是不太懂 apache+php+mysql +win平台,对无盘工作站的支持。
echo 可以输出二进制流的图片。没有问题。
img那种是图片 “文件”。在php中一般都是imagepng()什么的生成的用这个
(我也是刚学,大大们指导指导。先谢谢了。不要吝啬哦:))
$query = "SELECT pic FROM tablename WHERE id = $id"; if (!($result = @ mysql_query ($query,$connection)))
showerror(); $data = @ mysql_fetch_array($result); if (!empty($data["pic"]))
{
// Output the GIF MIME header
header("Content-Type: image/gif");
// Output the image
echo $data["pic"];
}
<?
/*****************************************************
** author:xiog xiangzhong
** date: 2004.3.31
** function:对考试管理页面的主页面
******************************************************/
include_once("test/UserTestDisplay.php");
$db = New NewUserTestClass();
$userid="xiong";
$dd=new Odbc();
$sql="select top 1 * from user_test where userid='".$userid."' order by testdate desc";
$dd->Query($sql);
if($rs=$dd->NextRecord())
$date=date("Y-m-d",$rs['testdate']);
?>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<link rel="stylesheet" href="../css/css.css">
<title>Qualification Mangement</title></head><body bgcolor="#E8E8E8" >
<table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr bgcolor="#336699">
<td class="PTitle" align="left">Test</td>
</tr>
<tr><td>
</td></tr>
</table>
<form name=form1 method='post' action=<?=$PHP_SELF?> >
<table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr><td>
<table>
<tr><td>Welcome <?=$userid?> coming Test.<br>Your Previous came at <?=$date?>
</table>
</td></tr>
<tr><td>
<table id=table4 >
<tr><td>
<?
include_once("include/gd_class2.php");
$db=New NewUserTestClass();
$db->Select("userid",$userid,"=");
$i=0;
while($result=$db->fetch())
{
echo $rs[$i][0]=$result['scores'];
echo " ";
echo $testid=$result['testid'];
echo " ";
echo $date[$i]=$result['testdate'];
echo " ";
$i++;
}
$cnt=$i;
echo $cnt."<br>";
for($i=0;$i<$cnt;$i++){
echo $rs[$i]."<br>";
}
if(!isset($trans)){
$trans=1;}
$report=new DrawImageReportClass();
//function SetImage($x,$y,$r,$g,$b,$tran)
$report->SetImage(500,300,255,255,255,0);//参数(长,宽,背影色R,G,B,是否透明1或0)
//function SetFont($size,$color)
$report->SetFont(1);//字体大小1-10
//$rs= array(0=> array("a","b","c","d"),1=> array("d","c","b","d"),2=> array("c","e","c"),3=>array("c","a","d"));//数值,用指定符号隔开
// $rs= array(0=> array(100,250),1=> array(450,400),2=> array(300,200));//数值,用指定符号隔开
//$case1 =array("a","b","c");
$case = array("my","Your","she");
//$rsx=array("question1","quetion2","qutstion3","question4","question5","question6");
//$rsx= array(1,2,3,4,5,6);
$rsy= array(20,40,60,80,100);
//$rsy= array("a","b","c","d","e");
$colors = array("FF0000","FFFF00","00FFFF","DDBBCC");
$report->SetRecords($rs,$testid,$rsy,$date,$colors,$trans,20);
//$report->SetRecords($rs,$user,$rsy,$rsx,$colors,1,20);
//参数(分隔数值的指定符号,数值变量,样式1为竖柱图2为横柱图3为折线图,距离)
$report->DrawReport();
header('Content-type: image/png');
echo "<img src='".$report->mShow.$report->mName."'>";
?>
</td></tr>
</table>
</td></tr>
<TR><TD align=center>
<input type=button value="New Test" onclick=add()>
</TD></TR>
<tr bgcolor="#336699"><td> </td></tr>
</table>
</form></body>
</html>