pChart does not render to web browser, only shows missing image

5.3k Views Asked by At

pCharts documentation says that you should be able to render the image to the browser using this code.

mypic.php

$myPicture->stroke;

mypage.html

<IMG SRC=‘mypic.php‘>

The img tag is supposed to invoke the php script. Within the PHP script, the stroke function sets the content-type: image/png.

So here is what I have:

netsales.php

<?php
     include('../class/pData.class.php');
     include('../class/pDraw.class.php');
     include('../class/pImage.class.php');

     /* query sales and create new image */

     $myPicture->stroke;
?>

index.php

<?php
     include ('netsales.php');
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
</head>
<body>
     <div>
          <img src="netsales.php" />
     </div>
</body>
</html>

I'm not getting any errors, just the red X for a missing image.

3

There are 3 best solutions below

0
On

I try something like this and works:

//html file//////////////////////
<?php include ('my.php'); ?>

<html>
<head></head>
<body>

<div> <img src="my.php" /> </div>

</body>

</html>
///////////////////////////////////


//my.php file/////////////////////////
<?php

 /* pChart library inclusions */ 
 include("pChart/class/pData.class.php"); 
 include("pChart/class/pDraw.class.php"); 
 include("pChart/class/pImage.class.php"); 


 //...


 $myPicture->autoOutput("picture.png"); 

?>
///////////////////////////////////
0
On

try removing the

<?php
     include ('netsales.php');
?>

From index.php, and add

header('Content-Type: image/png');

Before the Stroke call.

0
On

I just got it working for me I had comment include function in HTML file:

<?php //include ('my.php'); ?>