-1
<?php
$servername = "localhost";
$username = "root";
$password = "";
$dbname = "admin_panel";



$conn = new mysqli($servername, $username, $password, $dbname);

if ($conn->connect_error) {
    die("Connection failed: " . $conn->connect_error);
} 

$sql = "SELECT *
  FROM my_chart_data
  ORDER BY category ASC";
$result = $conn->query($sql);
echo("<SCRIPT LANGUAHE='JavaScript'>
var chart;


AmCharts.ready(function() {


  var chartData = AmCharts.loadJSON('data.php');


  chart = new AmCharts.AmSerialChart();
  chart.dataProvider = chartData;
  chart.categoryField = 'category';
  chart.dataDateFormat = 'YYYY-MM-DD';



  var graph1 = new AmCharts.AmGraph();
  graph1.valueField = 'value1';
  graph1.bullet = 'round';
  graph1.bulletBorderColor = "#FFFFFF";
  graph1.bulletBorderThickness = 2;
  graph1.lineThickness = 2;
  graph1.lineAlpha = 0.5;
  chart.addGraph(graph1);

  var graph2 = new AmCharts.AmGraph();
  graph2.valueField = 'value2';
  graph2.bullet = 'round';
  graph2.bulletBorderColor = "#FFFFFF";
  graph2.bulletBorderThickness = 2;
  graph2.lineThickness = 2;
  graph2.lineAlpha = 0.5;
  chart.addGraph(graph2);


  chart.categoryAxis.parseDates = true;


  chart.write("chartdiv");
</SCRIPT>");
        exit();
?>

i made a draft chart using phpmyadmin there is an syntax error in graph1. i dont no how to fix this can someone check code and correct this code if im wrong.

here is the error,

Parse error: syntax error, unexpected 'graph1' (T_STRING)

peterh
  • 11,875
  • 18
  • 85
  • 108

1 Answers1

0

You need to escape double quotes inside the string passed as argument to echo(). Look at the following changes:

-  graph1.bulletBorderColor = "#FFFFFF";
+  graph1.bulletBorderColor = \"#FFFFFF\";

-  graph2.bulletBorderColor = "#FFFFFF";
+  graph2.bulletBorderColor = \"#FFFFFF\";

-  chart.write("chartdiv");
+  chart.write(\"chartdiv\");
Nehal J Wani
  • 16,071
  • 3
  • 64
  • 89