1

我正在尝试根据 pchart 提供的示例生成图表。这是我的代码:

<?php
/* Include the pData class */

include("pchart/class/pData.class.php");

/* Create the pData object */

$myData = new pData();  

/* Connect to the MySQL database */

$db = mysql_connect("webhost", "user", "pass");

mysql_select_db("database",$db);


/* Build the query that will returns the data to graph */

$Requete = "SELECT * FROM `replies` WHERE `field` LIKE CONCAT ('%', Do you an interest in Green IT, '%')";

$Result  = mysql_query($Requete,$db);

$Yes=""; $No=""; $Undecided="";

while($row = mysql_fetch_array($Result));

{


/* Push the results of the query in an array */
$Yes[]   = $row["Yes"];
$No[] = $row["No"];
$Undecided[]    = $row["Undecided"];
}



/* Save the data in the pData array */

$myData->addPoints($Yes,"Yes");

$myData->addPoints($No,"No");

$myData->addPoints($Undecided,"Undecided");

?>

我得到的错误是:

Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in /home/a4728588/public_html/charts.php on line 30

这指向:

while($row = mysql_fetch_array($Result));

关于如何解决这个问题以便生成图表的任何想法?

提前致谢

4

1 回答 1

0

您的查询中有语法错误。 CONCAT()用于合并字符串。在您的查询中不需要。应该是这样的

LIKE '%Do you an interest in Green IT%'
于 2012-04-04T18:26:43.543 回答