I am trying to pass an xml string into the datasource argument and I keep getting an invalid data message when I load the page. Any help would be appreciated.
<head>
<title>FusionCharts XT - Column 2D Chart - Data from a database</title>
<link rel="stylesheet" type="text/css" href="css/style.css" />
<!-- Include the `fusioncharts.js` file. This file is needed to render the chart. Ensure that the path to this JS file is correct. Otherwise, it may lead to JavaScript errors. -->
<script src="fusioncharts/fusioncharts.js"></script>
</head>
<?php
include("fusioncharts/fusioncharts.php");
$servername = "localhost";
$username = "*****";
$password = "****";
$dbname = "***";
// Create connection
$dbhandle = new mysqli($servername, $username, $password, $dbname);
// Check connection
if ($dbhandle->connect_error) {
die("Connection failed: " . $dbhandle->connect_error);
}
$dbhandle = new mysqli($servername, $username, $password, $dbname);
// Render an error message, to avoid abrupt failure, if the database connection parameters are incorrect
if ($dbhandle->connect_error) {
exit("There was an error with your connection: ".$dbhandle->connect_error);
}
// Form the SQL query that returns the top 10 most populous countries
$strQuery = "SELECT * FROM scores";
//$retval = mysql_query( $sql, $conn );
// Execute the query, or else return the error message.
$result = $dbhandle->query($strQuery) or exit("Error code ({$dbhandle->errno}): {$dbhandle->error}");
//while($row = mysql_fetch_assoc($result)) {
// echo "Category :{$row['category']} <br> ".
// "score : {$row['score']} <br> ".
// "--------------------------------<br>";
// }
$strXML ="'<chart><categories>";
// If the query returns a valid response, prepare the XML string
if ($result) {
// The `$arrData` array holds the chart attributes and data
//$arrData["data"] = array();
// Push the data into the array
while($row = mysqli_fetch_array($result)) {
$strQuery2 = "select * from desirescores where ID =" . $row['ID'];
//echo $strQuery2;
$result2 = mysqli_query($dbhandle, $strQuery2) or die(mysqli_error());
$ors2 = mysqli_fetch_array($result2);
//Generate <set label='..' value='..'/>
//free the resultset
$strXML .= "<category label='" . $ors2['category'] . "' />";
mysqli_free_result($result2);
}
}
$strXML .= "</categories><dataset seriesName='Athlete Scores'>";
$strXML .="<set value='35' /><set value='48' /><set value='31' /><set value='40' /><set value='36' /><set value='36' /><set value='36' /><set value='36' /></dataset></chart>'";
echo $strXML;
$radarChart = new FusionCharts("radar", "myFirstChart" , 600, 300, "chart-1", "XML", $strXML);
$radarChart->render();
$dbhandle->close();
?>
<div id="chart-1"><!-- Fusion Charts will render here--></div>