Wrox Programmer Forums
Go Back   Wrox Programmer Forums > PHP/MySQL > PHP How-To
|
PHP How-To Post your "How do I do this with PHP?" questions here.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the PHP How-To section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old July 21st, 2003, 02:14 PM
Registered User
 
Join Date: Jul 2003
Posts: 5
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to wokoci Send a message via Yahoo to wokoci
Default jpgraph setup problem

I got the book on php graphics but it has been a real nightmare tring out the codes in chapter 7 due to problems installing jpgraph.

I am using windows 2000,
I have been trying for days to get the install write without success.
I have php 4.2.2 installed plus GD, which i have tested based on the test from the manual.

I have downloaded the jpgraph files and have same saved in a folder under the php folder.

I have never been able to get any of the example graphs to work, and get the following errors:


Warning: Failed opening '../jpgraph.php' for inclusion (include_path='.;c:\php4\pear') in C:\FoxServ\www\test.php on line 2

Warning: Failed opening '../jpgraph_line.php' for inclusion (include_path='.;c:\php4\pear') in C:\FoxServ\www\test.php on line 3

Fatal error: Cannot instantiate non-existent class: graph in C:\FoxServ\www\test.php on line 9

I have pointed my browser to the location of the example suites after saving the scr folder from the
jpgraph files in my web roots folder.

The graphs still will not display, but i can see the codes when i click on the position where the graphs should be.


Please help, i dont know where i am going wronge.


wokoci
 
Old July 21st, 2003, 03:15 PM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 836
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Well, it looks simple enough -- you're not including the jpgraph files properly.

You're trying to include '../jpgraph.php' from c:\FoxServe\www\test.php. So unless jpgraph.php is in c:\FoxServe\, or in c:\php4, it's not going to work.

Specify the correct path to jpgraph.php, or add the jpgraph src dir to your include path and just include "jpgraph.php" (no "../").

Take care,

Nik
http://www.bigaction.org/
 
Old July 21st, 2003, 07:42 PM
Registered User
 
Join Date: Jul 2003
Posts: 5
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to wokoci Send a message via Yahoo to wokoci
Default


Dear Nik,

I have made the changes as you recommended to my php.ini,
by adding the path to the include directory.

I now get the following error:

Parse error: parse error, unexpected '}' in c:\php4\pear\jpgraph.php on line 444

Fatal error: Class lineplot: Cannot inherit from undefined class plot in c:\php4\pear\jpgraph_line.php on line 24

the examples still do not display proparly also.

Is it neccessary to enable the cashe and font facility provided by
jpgraph?


Please help!!

Wokoci
 
Old July 21st, 2003, 11:05 PM
richard.york's Avatar
Wrox Author
 
Join Date: Jun 2003
Posts: 1,706
Thanks: 0
Thanked 6 Times in 6 Posts
Default

Quote:
quote:Parse error: parse error, unexpected '}' in c:\php4\pear\jpgraph.php on line 444
This means you've left out a curly brace or have one too many. You need to proofread your code to get rid of this error. Albeit at or near line 444 - though curly brace parse errors can sometimes be anywhere in the script.

Correcting that error could by all rights correct your other error. Feel free to post some code, it helps us better understand your questions.

Quote:
quote:Is it necessary to enable the cashe and font facility provided by
jpgraph?
If it were me I would have a (further) look at the documentation. If the script requires a particular font that could cause it to display improperly. Again, it helps to see the code associated with your questions.

: )
Rich

:::::::::::::::::::::::::::::::::
Smiling Souls
http://www.smilingsouls.net
:::::::::::::::::::::::::::::::::
 
Old July 22nd, 2003, 01:27 AM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 836
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Rich -- this doesn't necessarily mean that he's left any curly braces out. jpgraph is a freely available PHP software library; if there are any parse errors in the code, they're not likely to be found in the public stable release.

Still, it's worth looking at WHAT is near line 444 in that file; perhaps something's not being defined or included properly...


Take care,

Nik
http://www.bigaction.org/
 
Old July 22nd, 2003, 06:09 AM
Registered User
 
Join Date: Jul 2003
Posts: 5
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to wokoci Send a message via Yahoo to wokoci
Default

thanks for all the responces so far. I have modified my include_path to c:\foxsev\www. and i now get the following error:

Warning: Failed opening 'jpgraph.php' for inclusion (include_path='.c:\foxserv') in C:\FoxServ\www\test.php on line 2

Warning: Failed opening 'jpgraph_line.php' for inclusion (include_path='.c:\foxserv') in C:\FoxServ\www\test.php on line 3

Fatal error: Cannot instantiate non-existent class: graph in C:\FoxServ\www\test.php on line 9

the following a the sample i am trying to view:

<?php
include ( "jpgraph.php");
include ("jpgraph_line.php");

// Some data
$ydata = array(11,3, 8,12,5 ,1,9, 13,5,7 );

// Create the graph. These two calls are always required
$graph = new Graph(350, 250,"auto");
$graph->SetScale( "textlin");

// Create the linear plot
$lineplot =new LinePlot($ydata);
$lineplot ->SetColor("blue");

// Add the plot to the graph
$graph->Add( $lineplot);

// Display the graph
$graph->Stroke();
?>

PLease help
 
Old July 22nd, 2003, 02:11 PM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 836
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Your include path looks screwy... ".c:\foxserv".

Again, where did you install/unzip the jpgraph library? That directory should be in your include path. Be sure to properly separate the directories in your include path.

Also, make sure that error_reporting = E_ALL.


Take care,

Nik
http://www.bigaction.org/
 
Old July 22nd, 2003, 02:36 PM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 836
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Okay, I just downloaded the jpgraph library, unzipped it to a directory, added the src directory to my include_path, and voila -- it worked.

Here's the sample script I used to test my installation. Note that this script is taken directly from the jpgraph documentation, with one minor set of modifications. "..\" was removed from the include lines; for example:
    include("..\jpgraph.php");
was changed to
    include("jpgraph.php");

Code:
<?php
// $Id: listfontsex1.php,v 1.3 2002/10/25 22:44:15 aditus Exp $
include "jpgraph.php";
include "jpgraph_canvas.php";
include "jpgraph_canvtools.php";


$g = new CanvasGraph(550,450,'auto');
$scale = new CanvasScale($g);
$scale->Set(0,27,0,53);
$g->SetMargin(5,6,5,6);
$g->SetColor('white');
$g->SetMarginColor("teal");
$g->InitFrame();


$t = new CanvasRectangleText();
$t->SetFillColor('lightgreen');
$t->SetFontColor('navy');
$t->SetFont(FF_ARIAL,FS_NORMAL,16);
$t->Set("\n\n\n\n\n\n\n\n\n\n\nTTF Fonts",0.5,19,26,32);
$t->Stroke($g->img,$scale);


$t = new CanvasRectangleText();

$t->SetFillColor('');
$t->SetFontColor('black');
$t->SetColor('');
$t->SetShadow('');
$t->SetFont(FF_ARIAL,FS_BOLD,18);
$t->Set('Family',1,1,8);
$t->Stroke($g->img,$scale);

$t->Set('Italic style',9,1,8);
$t->Stroke($g->img,$scale);

$t->Set('Bold style',17.5,1,8);
$t->Stroke($g->img,$scale);


$t->SetFillColor('yellow');
$t->SetFontColor('black');
$t->SetColor('black');
$t->SetShadow('gray');

$r=6;$c=1;$w=7.5;$h=3.5;

$fonts=array(
    array("Font 0",FF_FONT0,FS_NORMAL),
    array("",FF_FONT0,FS_ITALIC),
    array("",FF_FONT0,FS_BOLD),

    array("Font 1",FF_FONT1,FS_NORMAL),
    array("",FF_FONT1,FS_ITALIC),
    array("Font 1 bold",FF_FONT1,FS_BOLD),

    array("Font 2",FF_FONT2,FS_NORMAL),
    array("",FF_FONT2,FS_ITALIC),
    array("Font 2 bold",FF_FONT2,FS_BOLD),

    array("Arial",FF_ARIAL,FS_NORMAL),
    array("Arial italic",FF_ARIAL,FS_ITALIC),
    array("Arial bold",FF_ARIAL,FS_BOLD),

    array("Verdana",FF_VERDANA,FS_NORMAL),
    array("Verdana italic",FF_VERDANA,FS_ITALIC),
    array("Verdana bold",FF_VERDANA,FS_BOLD),


    array("Trebuche",FF_TREBUCHE,FS_NORMAL),
    array("Trebuche italic",FF_TREBUCHE,FS_ITALIC),
    array("Trebuche bold",FF_TREBUCHE,FS_BOLD),

    array("Georgia",FF_GEORGIA,FS_NORMAL),
    array("Georgia italic",FF_GEORGIA,FS_ITALIC),
    array("Georgia bold",FF_GEORGIA,FS_BOLD),

    array("Comic",FF_COMIC,FS_NORMAL),
    array("",FF_COMIC,FS_ITALIC),
    array("Comic bold",FF_COMIC,FS_BOLD),

    array("Courier",FF_COURIER,FS_NORMAL),
    array("Courier italic",FF_COURIER,FS_ITALIC),
    array("Courier bold",FF_COURIER,FS_BOLD),


    array("Times normal",FF_TIMES,FS_NORMAL),
    array("Times italic",FF_TIMES,FS_ITALIC),
    array("Times bold italic",FF_TIMES,FS_BOLDITALIC),
    );


$n=count($fonts);

for( $i=0; $i < $n; ++$i ) {

    if( $i==9 ) $r += 3;

    if( $fonts[$i][0] ) {
    $t->SetTxt($fonts[$i][0]);
    $t->SetPos($c,$r,$w,$h);
    $t->SetFont($fonts[$i][1],$fonts[$i][2],13);
    $t->Stroke($g->img,$scale);
    }

    $c += $w+1;
    if( $c > 30-$w-2 ) {
    $c = 1;
    $r += 4;
    }

}

$g->Stroke();
?>
For reference, my include path is:
  ".;c:\WebHome\lib\jpgraph-1.12.2\src"


Take care,

Nik
http://www.bigaction.org/
 
Old July 24th, 2003, 05:17 PM
Registered User
 
Join Date: Jul 2003
Posts: 5
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to wokoci Send a message via Yahoo to wokoci
Default

Hi Nik,
I was able to get jpgraph working on my system based on the
explanation you gave below.

Thank you very much for all your help.

Regards

wokoci:D







Similar Threads
Thread Thread Starter Forum Replies Last Post
hyperlink+jpgraph tessy Beginning PHP 0 May 8th, 2008 01:35 AM
jpgraph+headers tessy Beginning PHP 0 May 7th, 2008 12:03 AM
Jpgraph Problem sandiphw Beginning PHP 0 September 26th, 2007 07:08 AM
Setup problem Martyn BOOK: ASP.NET Website Programming Problem-Design-Solution 1 June 24th, 2004 02:57 PM
jpGraph hosefo81 Beginning PHP 5 October 30th, 2003 01:43 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.