pChart 2.x forum
http://wiki.pchart.net/forum/

what's wrong
http://wiki.pchart.net/forum/viewtopic.php?f=1&t=2297
Page 1 of 1

Author:  HarryHirsch [ Tue Dec 06, 2011 8:15 pm ]
Post subject:  what's wrong

hi
i am trying to display some values from mysql database.

I use this code:

Code:
<?php
/* Include the pData class */
include("class/pData.class.php");

/* Create the pData object */
$MyData = new pData();

/* Connect to the MySQL database */
$db = mysql_connect("localhost", "webxxx", "password");
mysql_select_db("usr_xxx_6",$db);
/* Build the query that will returns the data to graph */
$Requete = "SELECT * FROM `messwerte`";
$Result  = mysql_query($Requete,$db);
while($row = mysql_fetch_array($Result))
{
  /* Get the data from the query result */
  $hoehe   = $row["hoehe"];
  $tempin = $row["tempin"];
  $tempout    = $row["tempout"];

  /* Save the data in the pData array */
  $myData->addPoints($hoehe,"hoehe");
  $myData->addPoints($tempin,"tempin");
  $myData->addPoints($tempout,"tempin");
}
  /* Build the query that will returns the data to graph */
$Requete = "SELECT * FROM `messwerte`";
$Result  = mysql_query($Requete,$db);
$hoehe=""; $tempin=""; $tempout="";
while($row = mysql_fetch_array($Result))
{
  /* Push the results of the query in an array */
  $hoehe[]   = $row["hoehe"];
  $tempin[] = $row["tempin"];
  $tempout[]    = $row["tempout"];
}

/* Save the data in the pData array  */
$myData->addPoints($hoehe,"hoehe");
$myData->addPoints($tempin,"tempin");
$myData->addPoints($tempout,"tempout");

/* Put the timestamp column on the abscissa axis */
$myData->setAbscissa("hoehe");

/* Associate the "Humidity" data serie to the second axis */
$myData->setSerieOnAxis("tempout", 1);

/* Name this axis "Time" */
$myData->setXAxisName("hoehe");
$myData->setAxisUnit(0,"m");

/* Specify that this axis will display time values
$myData->setXAxisDisplay(AXIS_FORMAT_TIME,"H:i");  */

/* First Y axis will be dedicated to the temperatures */
$myData->setAxisName(0,"tempin");
$myData->setAxisUnit(0,"°C");

/* Second Y axis will be dedicated to humidity */
$myData->setAxisName(1,"tempout");
$myData->setAxisUnit(0,"%");

?>


Errorcode:Fatal error: Call to a member function addPoints() on a non-object in /var/www/webxxx/html/pChart/test.php on line 39

Can anyone help me, please?

Author:  jean-damien [ Tue Dec 06, 2011 8:20 pm ]
Post subject:  Re: what's wrong

Aloha,

You're creating a pData object called $MyData and then adding points to another object called $myData.

It's just an upercase issue ;o)

Kind regards,
JD.

Author:  HarryHirsch [ Tue Dec 06, 2011 8:41 pm ]
Post subject:  Re: what's wrong

thanks for the quick answer,
now my code is:
Code:
<?php
/* Include the pData class */
include("class/pData.class.php");

/* Create the pData object */
$MyData = new pData();

/* Connect to the MySQL database */
$db = mysql_connect("localhost", "webXXX", "password");
mysql_select_db("usr_webxxx_6",$db);
/* Build the query that will returns the data to graph */
$Requete = "SELECT * FROM `messwerte`";
$Result  = mysql_query($Requete,$db);
while($row = mysql_fetch_array($Result))
{
  /* Get the data from the query result */
  $hoehe   = $row["hoehe"];
  $tempin = $row["tempin"];
  $tempout    = $row["tempout"];

  /* Save the data in the pData array */
  $myData->addPoints($hoehe,"hoehe");
  $myData->addPoints($tempin,"tempin");
  $myData->addPoints($tempout,"tempin");
}

/* Put the timestamp column on the abscissa axis */
$myData->setAbscissa("hoehe");

/* Associate the "Humidity" data serie to the second axis */
$myData->setSerieOnAxis("tempout", 1);

/* Name this axis "Time" */
$myData->setXAxisName("hoehe");
$myData->setAxisUnit(0,"m");

/* Specify that this axis will display time values
$myData->setXAxisDisplay(AXIS_FORMAT_TIME,"H:i");  */

/* First Y axis will be dedicated to the temperatures */
$myData->setAxisName(0,"tempin");
$myData->setAxisUnit(0,"°C");

/* Second Y axis will be dedicated to humidity */
$myData->setAxisName(1,"tempout");
$myData->setAxisUnit(0,"%");

?>


Fatal error: Call to a member function addPoints() on a non-object in /var/www/webxxx/html/pChart/test.php on line 22


perhaps you can post a working code, please? my php is not good.

Page 1 of 1 All times are UTC
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group
http://www.phpbb.com/