2016-06-08 48 views
-1

收到错误消息:代码是不能工作得到错误

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

<?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); 
?> 
+0

在浏览器中查看源代码,你会看到这个'图像'有什么错误 – nospor

+1

你真的认为这是可读吗? –

+0

PHP的错误文件中记录了什么? –

回答

0

我觉得Header('Content-type: image/jpeg');是问题。

0

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

你没有指定该文件的路径。