shadkeene
05-23-2008, 01:17 AM
Hi,
I'm fairly new to php and gd, but I have created some graphs that take data from mysql and display it with a png. However, I'm now trying to use php and gd on a windows IIS server(other times have been using linux), and I'm now getting weird symbols when trying to display an image.
Here's my code:
<?php
error_reporting(E_ALL);
ini_set('display_errors', 1);
error_reporting(E_ALL);
error_reporting(E_ALL|E_STRICT);
// Define .PNG image
//header("Content-type: image/png");
$imgWidth=800;
$imgHeight=800;
// Create image and define colors
$image=imagecreate($imgWidth, $imgHeight)
or die("Cannot Initialize new GD image stream");
$red = imagecolorallocate ($image, 255, 0, 0);
$link = mysql_connect('localhost', 'root', '*daver*') or die ("Could not connect: " . mysql_error());
mysql_selectdb('test',$link) or die ("Can\'t use dbmapserver : " . mysql_error());
$tslilt0 = mysql_query("select summer_am_models.fcli_sve, summer_am_models.date, summer_pm_work.date_time from summer_am_models, summer_pm_work
where day(summer_am_models.date)=day(summer_pm_work.date_time) and summer_pm_work.tsn='TS' and summer_am_models.fcli_sve<0",$link);
if (!$tslilt0)
{
echo "no results ";
}
$tsligt0 = mysql_query("select summer_am_models.fcli_sve, summer_am_models.date, summer_pm_work.date_time from summer_am_models, summer_pm_work
where day(summer_am_models.date)=day(summer_pm_work.date_time) and summer_pm_work.tsn='NOCU' and summer_am_models.fcli_sve<0",$link);
if (!$tsligt0)
{
echo "no results ";
}
$ntimestslilt0 = mysql_num_rows($tslilt0);
$ntimestsligt0 = mysql_num_rows($tsligt0);
$a=$ntimestslilt0*30;
$b=$ntimestsligt0*30;
imagefilledrectangle($image, 0, (800-$a), 10, 800, $red);
imagefilledrectangle($image, 10, (800-$b), 20, 800, $red);
imagepng($image);
var_dump(gd_info());
mysql_close($link);
?>
And here's my output:
‰PNG IHDR á¾”+PLTEÿâ 7eIDATxœíÁ1 õOm x ;¯@Ó%‡IEND®B`‚array(12) { ["GD Version"]=> string(27) "bundled (2.0.34 compatible)" ["FreeType Support"]=> bool(true) ["FreeType Linkage"]=> string(13) "with freetype" ["T1Lib Support"]=> bool(true) ["GIF Read Support"]=> bool(true) ["GIF Create Support"]=> bool(true) ["JPG Support"]=> bool(true) ["PNG Support"]=> bool(true) ["WBMP Support"]=> bool(true) ["XPM Support"]=> bool(false) ["XBM Support"]=> bool(true) ["JIS-mapped Japanese Font Support"]=> bool(false) }
I've installed php_g2.dll in my extensions directory and it seems to be working correctly based on the test array output. I've tried other random imagestrings and I get the same weird symbols. Thanks for any help!
Shad
I'm fairly new to php and gd, but I have created some graphs that take data from mysql and display it with a png. However, I'm now trying to use php and gd on a windows IIS server(other times have been using linux), and I'm now getting weird symbols when trying to display an image.
Here's my code:
<?php
error_reporting(E_ALL);
ini_set('display_errors', 1);
error_reporting(E_ALL);
error_reporting(E_ALL|E_STRICT);
// Define .PNG image
//header("Content-type: image/png");
$imgWidth=800;
$imgHeight=800;
// Create image and define colors
$image=imagecreate($imgWidth, $imgHeight)
or die("Cannot Initialize new GD image stream");
$red = imagecolorallocate ($image, 255, 0, 0);
$link = mysql_connect('localhost', 'root', '*daver*') or die ("Could not connect: " . mysql_error());
mysql_selectdb('test',$link) or die ("Can\'t use dbmapserver : " . mysql_error());
$tslilt0 = mysql_query("select summer_am_models.fcli_sve, summer_am_models.date, summer_pm_work.date_time from summer_am_models, summer_pm_work
where day(summer_am_models.date)=day(summer_pm_work.date_time) and summer_pm_work.tsn='TS' and summer_am_models.fcli_sve<0",$link);
if (!$tslilt0)
{
echo "no results ";
}
$tsligt0 = mysql_query("select summer_am_models.fcli_sve, summer_am_models.date, summer_pm_work.date_time from summer_am_models, summer_pm_work
where day(summer_am_models.date)=day(summer_pm_work.date_time) and summer_pm_work.tsn='NOCU' and summer_am_models.fcli_sve<0",$link);
if (!$tsligt0)
{
echo "no results ";
}
$ntimestslilt0 = mysql_num_rows($tslilt0);
$ntimestsligt0 = mysql_num_rows($tsligt0);
$a=$ntimestslilt0*30;
$b=$ntimestsligt0*30;
imagefilledrectangle($image, 0, (800-$a), 10, 800, $red);
imagefilledrectangle($image, 10, (800-$b), 20, 800, $red);
imagepng($image);
var_dump(gd_info());
mysql_close($link);
?>
And here's my output:
‰PNG IHDR á¾”+PLTEÿâ 7eIDATxœíÁ1 õOm x ;¯@Ó%‡IEND®B`‚array(12) { ["GD Version"]=> string(27) "bundled (2.0.34 compatible)" ["FreeType Support"]=> bool(true) ["FreeType Linkage"]=> string(13) "with freetype" ["T1Lib Support"]=> bool(true) ["GIF Read Support"]=> bool(true) ["GIF Create Support"]=> bool(true) ["JPG Support"]=> bool(true) ["PNG Support"]=> bool(true) ["WBMP Support"]=> bool(true) ["XPM Support"]=> bool(false) ["XBM Support"]=> bool(true) ["JIS-mapped Japanese Font Support"]=> bool(false) }
I've installed php_g2.dll in my extensions directory and it seems to be working correctly based on the test array output. I've tried other random imagestrings and I get the same weird symbols. Thanks for any help!
Shad