2016-06-08 53 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'

你沒有指定該文件的路徑。