Php 在pChart图形中显示来自MYSQL的数据

Php 在pChart图形中显示来自MYSQL的数据,php,mysql,html,pchart,Php,Mysql,Html,Pchart,嗨,我是pChart的新手 我想用pChart从我的sqldata构建一个图表。 我写了这段代码 <?php /*pChart library inclusions*/ include("../pChart2.1.4/class/pData.class.php"); include("../pChart2.1.4/class/pDraw.class.php"); include("../pChart2.1.4/class/pImage.class.php"); /*Create and

嗨,我是pChart的新手

我想用pChart从我的sqldata构建一个图表。 我写了这段代码

<?php

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

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

// Datenbankeinstellungen
define("db_user", "XXX");
define("db_password", "XXX");
define("db_server", "localhost");
define("db_db_name", "XXX");

// Verbinden und Datenbank auswählen
mysql_connect(db_server, db_user, db_password) or die(mysql_error());
mysql_select_db(db_db_name) or die(mysql_error());

$sql ="SELECT*FROM XXXXXX WHERE sensor_ID = '40'";

// Abfrage ausführen
$result = mysql_query($sql) or die(mysql_error());
$ergebnis = mysql_query($sql);
while ($row=mysql_fetch_row($ergebnis))
{
/*Push the results of the query in an array*/
$uhrzeit[] = $row[2];
$Voc_Wert [] = $row[3];

}

/* Save the data in the pData array */
$MyData->addPoints($uhrzeit,$row[2]);
$MyData->addPoints($Voc_Wert,$row[3]);
/*Create the pChart object*/
$mypicture = new pImage (700,230,$MyData);
/* Turn of Antialiasing */
$myPicture->Antialias = FALSE;

/* Add a border to the picture */
$myPicture->drawRectangle(0,0,699,229,array("R"=>0,"G"=>0,"B"=>0));

/* Write the chart title */
$myPicture->setFontProperties(array("FontName"=>"../fonts/Forgotte.ttf","FontSize"=>11));
$myPicture->drawText(150,35,"VOC-   Messung",array("FontSize"=>20,"Align"=>TEXT_ALIGN_BOTTOMMIDDLE));

/* Set the default font */
$myPicture->setFontProperties(array("FontName"=>"../fonts/pf_arma_five.ttf","FontSize"=>6));

/* Define the chart area */
$myPicture->setGraphArea(60,40,650,200);

/* Draw the scale */
$scaleSettings =   array("XMargin"=>10,"YMargin"=>10,"Floating"=>TRUE,"GridR"=>200,"GridG"=>200,"GridB"=>200,"DrawSubTicks"=>TRUE,"CycleBackground"=>TRUE);
$myPicture->drawScale($scaleSettings);

/* Turn on Antialiasing */
$myPicture->Antialias = TRUE;

/* Draw the line chart */
$myPicture->drawLineChart();

/* Write the chart legend */
$myPicture->drawLegend(540,20,array("Style"=>LEGEND_NOBORDER,"Mode"=>LEGEND_HORIZONTAL));

/* Render the picture (choose the best way) */
$myPicture->autoOutput("pictures/example.drawLineChart.simple.png");


 ?>
我总是犯这样的错误: 警告:从第41行C:-\display.php中的空值创建默认对象

致命错误:在第44行的C:-\display.php中调用未定义的方法stdClass::drawRectangle

我做错了什么?
我将感谢任何帮助。谢谢

你能发布stdClass代码吗?对不起,阿拉古,我没有看到你的评论。你说的stdClass是什么意思?