Sign in to follow this  
AdamVanBuskirk

Xml Error Regarding Setxmldata And Php

Recommended Posts

I am getting the error:

 

 

SyntaxError: missing ; before statement <set label='PowerCharts' value='339800' />

 

regarding the below code. When I include the exact same XML in a data file and use setXMLUrl instead of setXMLData, it works fine. I tried without the "" at the beginning and end as well as loading the variable chartInfo in PHP first and still the same result.

 

Any help would be greatly appreciated. Thanks.

 



   <div id="chartdiv" align="center" ></div>

   <?php


     echo "
     <script type='text/javascript'>

    var chartInfo = \"\"
     <chart 
      caption='AVG Days to Completion'
      subCaption='sub title' 
      showLabels='0' 
      showLegend='1'
      bgColor='FFFFFF' 
      borderColor='616E9D' 
      borderThickness='5' 
      baseFontColor='FFFFFF' 
      legendbgColor='414E7D'>
      <set label='test 1' value='232400' />
      <set label='test 2' value='339800' />
      <set label='test 3' value='411900' />
      <set label='test 4' value='398400' />
     </chart>\"\";    


    FusionCharts.setCurrentRenderer('javascript');
    var myChart = new FusionCharts('../../FusionCharts/Doughnut2D.swf','chart','400','300','0','1');
    myChart.setXMLData(chartInfo);
    myChart.render('chartdiv');

     </script>
     ";



Share this post


Link to post
Share on other sites
Guest Sashibhusan

Hi,

 

Could you please add only one slash "\" just before double quote to escape the double quote in the PHP string variable "chartInfo"?

 

Your Code:

var chartInfo = \"\"...\"\";

 

Replace with:

var chartInfo = \"...\";

 

Also, please remove the "\n" character from the XML string.

 

Please find the below code (modified your code as per the suggestion above mentioned), for your reference.

 

Ref. Code:

<?php
echo "
<script type='text/javascript'>
var chartInfo = \"<chart caption='AVG Days to Completion' subCaption='sub title' showLabels='1' showLegend='1' bgColor='FFFFFF' borderColor='616E9D' borderThickness='5' baseFontColor='FFFFFF' legendbgColor='414E7D'><set label='test 1' value='232400' /><set label='test 2' value='339800' /><set label='test 3' value='411900' /><set label='test 4' value='398400' /></chart>\";	
FusionCharts.setCurrentRenderer('javascript');
var myChart = new FusionCharts('../../FusionCharts/Doughnut2D.swf','chart','400','300','0','1');
myChart.setXMLData(chartInfo);
myChart.render('chartdiv');
</script>
";
?>

 

Hope this helps!

Edited by Sashibhusan

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this