Sign in to follow this  
Rahul Kumar

Inconsistent XML Results returned from PHP script

Recommended Posts

I'm using a PHP script to get a value from MySQL to be charted on the Angular Guage. The Chart displays - but it is always at 100%. I put the chart in debug mode and it displays the dataURL correctly. When I click on the URL from the debug screen - it displays:

 

 

 

 

 

< chart bgColor="FFFFFF" lowerLimit="0" upperLimit="100" upperLimitDisplay="Bad" lowerLimitDisplay="Good" gaugeStartAngle="180" gaugeEndAngle="0" palette="1" numberSuffix="%" tickValueDistance="20" showValue="1" showBorder="0">

 

< colorRange>

 

< color minvalue="0" maxvalue="50" code="228B22"/>

 

< color minvalue="50" maxvalue="100" code="FF0000"/>

 

< /colorRange>

 

< dials>

 

< dial value="21"rearExtension="10"/>

 

< /dials>

 

< /chart>

 

 

 

However the debug screen displays the following XML:

 

 

 

< ?xml version="1.0"?>

 

< chart bgColor="FFFFFF" lowerLimit="0" upperLimit="100" upperLimitDisplay="Bad" lowerLimitDisplay="Good" gaugeStartAngle="180" gaugeEndAngle="0" palette="1" numberSuffix="%" tickValueDistance="20" showValue="1" showBorder="0">

 

< colorRange>

 

< color minvalue="0" maxvalue="50" code="228B22" />

 

< color minvalue="50" maxvalue="100" code="FF0000" />

 

< /colorRange>

 

< dials>

 

< dial value="" rearExtension="10" />

 

< /dials>

 

< /chart>

 

 

 

and the following message:

 

 

 

Invalid data: Invalid number specified in XML. FusionCharts can accept number in pure numerical form only.

 

If your number formatting (thousand and decimal separator) is different, please specify so in XML.

 

Also, do not add any currency symbols or other signs to the numbers.

 

 

 

 

 

Why would this occur - clicking on the URL looks like it retrieves valid XML with a value - but the XML in the debug window shows no value - hence the error and the chart displaying 100%

 

 

 

code is attached - turnover.html displays the chart and calls turnover.php

Edited by Guest

Share this post


Link to post
Share on other sites

figured it out - My variables in the query string could contain '%' - the wild card character for ALL. Evidently the escape() encodes it - but for some reason the GET in the PHP script was not decoding it - or was incorrectly. I tried a number of different routines - but none would work correctly - so I added a bit of JS code to the calling HTML page:

 

 

 

if(site == '%') { site = 'ALL' };

 

 

 

Than on the other side - I use a case statement in the where clause looking for 'ALL' and replacing with '%' -

 

.....

 

and case when '".$site."' = 'ALL' then SCOUNT.SITEID like '%' else SCOUNT.SITEID = '".$site."' end

 

.....

 

not the best solution but it works.

 

 

 

Is there a suggested way to decode special characters in PHP to get around this?

Edited by Guest

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