addPoints($No,"No"); $myData->addPo-6ren">
gpt4 book ai didi

php - 使用 pchart 和 mysql 创建图表 - 提供的示例中的正确语法

转载 作者:行者123 更新时间:2023-11-30 23:32:10 25 4
gpt4 key购买 nike

我正在尝试根据 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));

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

提前致谢

最佳答案

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

LIKE '%Do you an interest in Green IT%'

关于php - 使用 pchart 和 mysql 创建图表 - 提供的示例中的正确语法,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10017074/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com