代码无法获取错误

时间:2016-06-08 08:59:10

标签: php html image

收到错误消息:

  

无法显示,因为它包含一些错误。

<?php 
include("connection.php"); 
$height = 200; 
$width = 200; 
$border = 30; 
if($_GET['height']) {$height = $_GET['height'];} 
if($_GET['width']) {$width = $_GET['width'];} 
if($_GET['border']) {$border = $_GET['border'];} 
Header('Content-type: image/jpeg'); 
$image = ImageCreate($width+$border, $height+$border); 
$white = ImageColorAllocate($image, 255, 255, 255); 
$black = ImageColorAllocate($image, 0, 0, 0); 
$blueish = ImageColorAllocate($image, 120, 120, 255); 
$redish = ImageColorAllocate($image, 222, 66, 66); 
$grayish = ImageColorAllocate($image, 200, 200, 200); 
$purpleish = ImageColorAllocate($image, 200, 10, 200); 
ImageFill($image, 0,0, $black); 
ImageFilledRectangle ($image, 0,0,$border,$height+$border, $grayish); 
ImageFilledRectangle ($image, 0,$height, $border+$height,$border+$width, $grayish);
$sql = "SELECT Battery FROM battery_level ORDER BY DESC"; 
$result = mysqli_query( $sql, $conn ); 
$num = mysqli_num_rows($result);
$den = $num*2+1; 
$xspacing = intval($width/$den); 
$pos = -1; 
while ($row = mysqli_fetch_array($result)) 
{ 
   $pos = $pos +2; 
   $left = $pos*$xspacing; 
   $right = ($pos+1)*$xspacing;    
} 
ImageJpeg($image); 
ImageDestroy($image); 
?>

2 个答案:

答案 0 :(得分:0)

我认为Header('Content-type: image/jpeg');是个问题。

答案 1 :(得分:0)

试试这个 ImageJpeg($image, $path); //ex. $path = 'asset/image_name.jpg'

您没有指定此文件的路径。