PHP graphics wont work [Solved]

Problems with the Windows version of XAMPP, questions, comments, and anything related.

PHP graphics wont work [Solved]

Postby zenner » 03. March 2013 20:40

Hello.
Why does this code doesn't work on Xampp? It works fine in an online 'real' server but not on my local xampp.
Any ideas?
Any code that i've tested to generate graphics wont work locally.
Example:

Code: Select all
<?
// Add values to the graph
$graphValues=array(0,80,23,11,190,245,50,80,111,240,55);

// Define .PNG image
header("Content-type: image/png");
$imgWidth=250;
$imgHeight=250;

// Create image and define colors
$image=imagecreate($imgWidth, $imgHeight);
$colorWhite=imagecolorallocate($image, 255, 255, 255);
$colorGrey=imagecolorallocate($image, 192, 192, 192);
$colorBlue=imagecolorallocate($image, 0, 0, 255);

// Create border around image
imageline($image, 0, 0, 0, 250, $colorGrey);
imageline($image, 0, 0, 250, 0, $colorGrey);
imageline($image, 249, 0, 249, 249, $colorGrey);
imageline($image, 0, 249, 249, 249, $colorGrey);

// Create grid
for ($i=1; $i<11; $i++){
imageline($image, $i*25, 0, $i*25, 250, $colorGrey);
imageline($image, 0, $i*25, 250, $i*25, $colorGrey);
}

// Create line graph
for ($i=0; $i<10; $i++){
imageline($image, $i*25, (250-$graphValues[$i]), ($i+1)*25, (250-$graphValues[$i+1]), $colorBlue);
}

// Output graph and clear image from memory
imagepng($image);
imagedestroy($image);
?>


Thanks.
zenner
 
Posts: 2
Joined: 03. March 2013 20:34
XAMPP Version: 5.6.3
Operating System: Windows XP

Re: PHP graphics wont work

Postby WilliL » 03. March 2013 20:50

Hi zenner,

please try "<?php" instead "<?"
Willi
WilliL
 
Posts: 621
Joined: 08. January 2010 10:54
XAMPP Version: 5.5.19
Operating System: Win7Home Prem 64 SP1

Re: PHP graphics wont work

Postby zenner » 03. March 2013 20:54

WilliL wrote:Hi zenner,

please try "<?php" instead "<?"



Oooops.... it was that :oops:
Thanks, solved!!
zenner
 
Posts: 2
Joined: 03. March 2013 20:34
XAMPP Version: 5.6.3
Operating System: Windows XP


Return to XAMPP for Windows

Who is online

Users browsing this forum: No registered users and 30 guests