我正在尝试根据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));
有关如何解决这个问题的想法,以便生成图表吗?
提前致谢
答案 0 :(得分:0)
您的查询中存在语法错误。 CONCAT()
用于合并字符串。你的查询中不需要。应该是这样的
LIKE '%Do you an interest in Green IT%'