|
|
|
|
Page 1 of 1
|
[ 3 posts ] |
|
Author |
Message |
HarryHirsch
New pChart user
Joined: Tue Dec 06, 2011 8:08 pm Posts: 2
|
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 39Can anyone help me, please?
|
Tue Dec 06, 2011 8:15 pm |
|
|
jean-damien
Site Admin
Joined: Thu Dec 02, 2010 2:31 pm Posts: 409 Location: France
|
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.
|
Tue Dec 06, 2011 8:20 pm |
|
|
HarryHirsch
New pChart user
Joined: Tue Dec 06, 2011 8:08 pm Posts: 2
|
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 22perhaps you can post a working code, please? my php is not good.
|
Tue Dec 06, 2011 8:41 pm |
|
|
|
Page 1 of 1
|
[ 3 posts ] |
|
Who is online |
Users browsing this forum: No registered users and 5 guests |
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot post attachments in this forum
|
|
|
|