Page 1 of 1

Help me ASAP - images error

Posted: Mon Apr 23, 2007 6:54 am
by kumarangopi
feyd | Please use

Code: Select all

,

Code: Select all

and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read:  [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]


1) Environment : Red Hat Linux 5.x
2) PHP version 2.x
3) Apache
4) I have used xampp for installing php and apache
5)example.php

Code: Select all

<?php
 include('GrowthChart.class.php');
 $patientXData = array(2,  4,  6,  8, 10, 12);
 $patientYData = array(36, 40, 42.2, 44, 45, 45.8 );
 $xvals = join(',', $patientXData);
 $yvals = join(',', $patientYData);
 
?>
<html>
<head>
 <title>Growth Chart Example</title>
</head>
<body>
 <img src="chart.php?style=<?= GrowthChart::STYLE_HEAD_AGE ?>&sex=<?= GrowthChart::SEX_MALE ?>&maxage=35&xvals=<?= $xvals ?>&yvals=<?= $yvals ?>" />
</body>
</html>
chart.php:

Code: Select all

<?php
include_once('GrowthChart.class.php');
import_request_variables('g', 'url_');
$style = null;
$sex = null;
$maxage = null;
$width = null;
$height = null;
// check for minimum required variables
if (!isset($url_style) || !isset($url_sex) || !isset($url_maxage))
{
 die('One or more expected request variables not present.');
}
// check style value
if (!is_numeric($url_style) || (int)$url_style < 0 || (int)$url_style > 5)
{
 die('Style value out of range: ' . $url_style);
}
$style = $url_style;
// check sex value
if (!is_numeric($url_sex) || $url_sex < 1 || $url_sex > 2)
{
 die('Sex value out of range: ' . $url_sex);
}
$sex = $url_sex;
// check maximum age value
if (!is_numeric($url_maxage) || $url_maxage < 0)
{
 die('Maximum age value out of range: ' . $url_maxage);
}
$maxage = $url_maxage;
// check image width
if (isset($url_width) && !is_numeric($url_width))
{
 die('Image width value out of range: ' . $url_width);
}
$width = (isset($url_width) ? $url_width : 800);
// check image height
if (isset($url_height) && !is_numeric($url_height))
{
 die('Image height value out of range: ' . $url_height);
}
$height = (isset($url_height) ? $url_height : 800);

$patientXarray = null;
$patientYarray = null;
// check patient data values
// expecting comma-separated lists of x coordinates and y coordinates
if (isset($url_xvals) && isset($url_yvals))
{
 $paX = split(',', $url_xvals);
 $paY = split(',', $url_yvals);
 
 if (sizeof($paX) == sizeof($paY))
 {
  $okay = true;
  foreach ($paX as $value)
  {
   if (!is_numeric($value))
    $okay = false;
  }
  
  foreach ($paY as $value)
  {
   if (!is_numeric($value))
    $okay = false;
  }
  
  if ($okay)
  {
   $patientXarray = $paX;
   $patientYarray = $paY;
  }
 }
}

$chart = new GrowthChart($style, $sex, $maxage, $width, $height, $patientXarray, $patientYarray);
$chart->render();
?>
This my text.When Iam running example.php, Iam getting erorr 'image cannot be displayed,since it contains errors' can you pls help me pls.I have check output buffering in s/opt/lampp/etc/php.ini, it is off.I removed space after last line in example,chart,growthchart.class,jpgraph,jpgraph-line,jpgraph-restat php files

Please Kindly help me ASAP


feyd | Please use

Code: Select all

,

Code: Select all

and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read:  [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]

Posted: Mon Apr 23, 2007 8:16 am
by superdezign
Usually, when you post code for us to help you with, you should have already done a good amount of debugging yourself and know pretty much where the problem lies. It doesn't sound like you have, and you just assumed that your code was right. Anything could have gone wrong from your variable validation to the creation of your arrays.

You aren't giving us much. From the sound of things, the error message is generated by $chart->render(). Have you looked at the class' code? I'm sure there's something that you are missing. Maybe your array isn't formatted correctly.

And just a small suggestion, in your foreach loops, after setting $okay=false, you should break.

Posted: Mon Apr 23, 2007 10:35 am
by pickle
Maybe your headers aren't being sent properly?

Posted: Mon Apr 23, 2007 10:40 am
by onion2k
It's a GD problem. Open up GrowthChart.class.php, find the bit that outputs the Content-Type header and the image data, comment them both out, and then load the image in a browser. That will tell you what the problem is.