关于图形 是不是没有输出header头?这个: header ("Content-type: image/png"); 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 下面显示乱码,?????????! <html> <body> <?php header ("Content-type: image/gif"); //这个最好要, 有些时候不要似乎也可以$im = @imagecreate (50, 100) or die ("Cannot Initialize new GD image stream");$background_color = imagecolorallocate ($im, 255, 255, 255);$text_color = imagecolorallocate ($im, 233, 14, 91);imagestring ($im, 1, 5, 5, "A Simple Text String", $text_color);imagepng ($im); // 你少了这个 这个最关键.?> </body> </html> 有的,header ("Content-type: image/png")这一句不会丢的,hehe,yqcxm(yqcxm) 的过程也是显示乱码,必须把<html><body>等去掉之后才能正常显示,奇怪的是,使用gif没有掉示下载,可以显示,而如果使用png则没有显示,弹出一个下载窗来,怎么回事. header(...)必须放在所有输出语句之前。如果你只要输出图片:header("Content-Type:image/png");处理语句(记住,这里不能有任何输出语句);imagepng(..);结束;<html> <body> <?php ...?>实际上在这之前已经输出缺省头信息了。<html> <body>将作为输出信息输出到客户端。 header之前有输出会有出错提示,且乱码 比如下面的代码,我要在按提交后,经过计算用图形显示出结果,那么应该把图形函数写在哪里才不会出错?===========================================<html><body><form method="POST" action="<? $_SERVER['PHP_SELF'] ?>"><input type="radio" value="V1" name="R1">1</p><p><input type="radio" name="R1" value="V2">2</p><p><input type="radio" name="R1" value="V3">3</p><p><input type="radio" name="R1" value="V4">4</p><p><input type="submit" value="提交" name="B1"></p></form></body></html><?if (isset($_POST['B1'])) {if (isset($_POST['R1'])) {$a=$_POST['R1'];$conn=mysql_connect("","","") or die ("无法联接到数据库!!") ;mysql_select_db("no1",$conn);$sql="select one,two,three,four from vote where id=1";$result=mysql_query($sql,$conn);$ru=mysql_fetch_array($result);switch ($a) { case "V1": $nowvote=$ru[0]+1; $ud="update vote set one='$nowvote' where id=1"; break; case "V2": $nowvote=$ru[1]+1; $ud="update vote set two='$nowvote' where id=1"; break; case "V3": $nowvote=$ru[2]+1; $ud="update vote set three='$nowvote' where id=1"; break; case "V4": $nowvote=$ru[3]+1; $ud="update vote set four='$nowvote' where id=1"; break; }mysql_query($ud,$conn);$result=mysql_query($sql,$conn);$ru=mysql_fetch_array($result);echo "one=".$ru[0].'<br>';echo "two=".$ru[1].'<br>';echo "three=".$ru[2].'<br>';echo "four=".$ru[3].'<br>';echo "a=".$a.'<br>';}else {echo "你没有选择";}}?>===========================================================我曾使用过ob_start()来控制输出,结果依然,无法,请大家多指点. 其中的:echo "one=".$ru[0].'<br>';echo "two=".$ru[1].'<br>';echo "three=".$ru[2].'<br>';echo "four=".$ru[3].'<br>';echo "a=".$a.'<br>';是我用来检查数据获取是否正确的,以后是要删除的. 你vote表中one,tow,three,four存放的是什么数据? 数字啊,有四个可选项,one two,three,four四个字段各储存各项的投票合计人数,其实表中还有一个id自增字段及5,6,7,8,9...等等共二十个字段,我的想法是做一个表就行了,以id来区分不同的投票,二十个选项应该适合大部份场合使用了,有多少选项就用多少字段,具体问题由代码来处理.hehe,是不是有点不大正规?我这个是想做成一提交,经过计算产生一个如下一样的图形:********** 20%**************** 35%***** 16%************* 29% 图片和文字不能放在同一个PHP中做处理! 分开写, 然后用img来调用显示图片的PHP文件. 如何将这段文字显示出来,在textarea中,要有换行的格式 xampp配置php环境,chrome能打开ie却打不开php,总提示下载 php面向对象练习题求帮助 PHP问题求助 PHP为何显示不出记录? ORD()函数的具体意思 php中如何得到某些页面元素的值?急,在线等答!!! 请问查找数据库里的内容代码怎么写? 一个关于MySQL的问题! 加急! 如何实现推送?跪求大神 我想用PHP+MySql做一个树,请大家赐教!!! Cookie又不起作用了。
<body>
<?php
header ("Content-type: image/gif"); //这个最好要, 有些时候不要似乎也可以
$im = @imagecreate (50, 100)
or die ("Cannot Initialize new GD image stream");
$background_color = imagecolorallocate ($im, 255, 255, 255);
$text_color = imagecolorallocate ($im, 233, 14, 91);
imagestring ($im, 1, 5, 5, "A Simple Text String", $text_color);
imagepng ($im); // 你少了这个 这个最关键.
?>
</body>
</html>
yqcxm(yqcxm) 的过程也是显示乱码,必须把<html><body>等去掉之后才能正常显示,奇怪的是,使用gif没有掉示下载,可以显示,而如果使用png则没有显示,弹出一个下载窗来,怎么回事.
如果你只要输出图片:
header("Content-Type:image/png");
处理语句(记住,这里不能有任何输出语句);
imagepng(..);
结束;
<html>
<body>
<?php ...?>
实际上在这之前已经输出缺省头信息了。
<html>
<body>
将作为输出信息输出到客户端。
===========================================
<html>
<body>
<form method="POST" action="<? $_SERVER['PHP_SELF'] ?>">
<input type="radio" value="V1" name="R1">1</p>
<p><input type="radio" name="R1" value="V2">2</p>
<p><input type="radio" name="R1" value="V3">3</p>
<p><input type="radio" name="R1" value="V4">4</p>
<p><input type="submit" value="提交" name="B1"></p>
</form>
</body>
</html>
<?
if (isset($_POST['B1'])) {
if (isset($_POST['R1'])) {$a=$_POST['R1'];$conn=mysql_connect("","","") or die ("无法联接到数据库!!") ;mysql_select_db("no1",$conn);
$sql="select one,two,three,four from vote where id=1";
$result=mysql_query($sql,$conn);
$ru=mysql_fetch_array($result);
switch ($a) {
case "V1":
$nowvote=$ru[0]+1;
$ud="update vote set one='$nowvote' where id=1";
break;
case "V2":
$nowvote=$ru[1]+1;
$ud="update vote set two='$nowvote' where id=1";
break;
case "V3":
$nowvote=$ru[2]+1;
$ud="update vote set three='$nowvote' where id=1";
break;
case "V4":
$nowvote=$ru[3]+1;
$ud="update vote set four='$nowvote' where id=1";
break;
}
mysql_query($ud,$conn);
$result=mysql_query($sql,$conn);
$ru=mysql_fetch_array($result);
echo "one=".$ru[0].'<br>';
echo "two=".$ru[1].'<br>';
echo "three=".$ru[2].'<br>';
echo "four=".$ru[3].'<br>';
echo "a=".$a.'<br>';
}
else {echo "你没有选择";}
}
?>
===========================================================我曾使用过ob_start()来控制输出,结果依然,无法,请大家多指点.
echo "one=".$ru[0].'<br>';
echo "two=".$ru[1].'<br>';
echo "three=".$ru[2].'<br>';
echo "four=".$ru[3].'<br>';
echo "a=".$a.'<br>';
是我用来检查数据获取是否正确的,以后是要删除的.
**************** 35%
***** 16%
************* 29%