ホームページ  >  記事  >  バックエンド開発  >  $x、$y、$z がデータベースから読み取ってグラフィックを生成できないのはなぜですか?

$x、$y、$z がデータベースから読み取ってグラフィックを生成できないのはなぜですか?

WBOY
WBOYオリジナル
2016-06-13 13:06:38887ブラウズ

データベースから読み取った $x、$y、$z がグラフィックを生成できないのはなぜですか?

require("../Comm/Conn.php");データベース データ部分の読み取り
$result = mysqli_query($mysql, "select count(*) as nega from message whereattitude=-1");
$row = mysqli_fetch_assoc($result);
$x =(int)$row['nega'];
$result = mysqli_query($mysql, "attitude=0 のメッセージから count(*) をゼロとして選択します");
$row = mysqli_fetch_assoc($result );
$y=(int)$row['zero'];
$result = mysqli_query($mysql, "attitude=1 のメッセージから count(*) を posi として選択します");
$row = mysqli_fetch_assoc($result);
$z=(int)$row['posi'];
mysqli_free_result($result);
mysqli_close($mysql);
$total=$x+$y+$z; //統計グラフ部分を生成
$height=200;
$width=200;

$y1=$height-intval($ x/$total*$height,10);
$y2=$height-intval($y/$total*$height,10);
$y3=$height-intval($z/$total) *$height,10);

$im=imagecreatetruecolor($width,$height);
$white=imagecolorallocate($im,255,255,255);
$black=imagecolorallocate($im, 0,0,0);
$red=imagecolorallocate($im,255,0,0);
$blue=imagecolorallocate($im,0,0,255);
$green=imagecolorallocate($ im,0,255,0);

imagefill($im,0,0,$white);
imagerectangle($im,0,0,$width-1,$height-1,$black );
imagefilledrectangle($im,$width/10,$y1,3*$width/10,$height-2,$red);
imagefilledrectangle($im,4*$width/10,$ y2,6*$width/10,$height-2,$blue);
imagefilledrectangle($im,7*$width/10,$y3,9*$width/10,$height-2,$green );

画像文字列($im,5,30,180,$x,$white);
画像文字列($im,5,90,180,$y,$white);
画像文字列($im) ,5,150,180,$z,$red);

Header('Content-type:image/png');
imagepng($im);
imagedestroy($im);
?>


-----解決策---------
出力 $x $ y $z見てください、それは何ですか?それともSQLに何か問題があるのでしょうか?
------解決策---------
Header('Content-type:image/png ' );ヘッダーの小文字

------解決策---------
#1、#2 のサプリメントの場合、説明は次のとおりです。 true の場合、1. 最後の ?> を削除します。
2. 両方のファイルに BOM ヘッダーがないことを確認します。
3. $x+$y+$z != 0 を確認します。

------解決策------------------
それは奇妙です。ヘッダーをコメントアウトして、見てください//Header('Content-type:image/png');

------解決策---------
$s = file_get_contents('http://www .yisee.org/00Home/Messagegraph.php');print_r(unpack('H*', $s));

get
Array ( [1] => 80802 ....

この efbbbf は単なる BOM ヘッダーではありませんか?

声明:
この記事の内容はネチズンが自主的に寄稿したものであり、著作権は原著者に帰属します。このサイトは、それに相当する法的責任を負いません。盗作または侵害の疑いのあるコンテンツを見つけた場合は、admin@php.cn までご連絡ください。