Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7545303
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T08:53:33+00:00 2026-05-30T08:53:33+00:00

I am new to this forum and to Open Flash Chart 2. I just

  • 0

I am new to this forum and to Open Flash Chart 2. I just installed a chart in one of my website, which works fine. I am getting the chart points dynamically through a URL using file_get_contents in PHP. Everything works fine, but some URLs doesn’t has points data so the chart is returning me the JSON error

Open Flash Chart

JSON Parse Error [Syntax Error]
Error at character 0, line 1:

0: <br />

I know why the error is punched, but I want to get rid of this, instead it should show “Not enough data to map the chart”.

Is there any solution for this?

Thank you in advance 😀

EDIT:
MY CODE:

<?php
include 'oc/php-ofc-library/open-flash-chart.php';
$url = 'http://*****.api3.nextbigsound.com/metrics/artist/'.$_REQUEST['artistId'].'.json';
$file = file_get_contents($url);

$data = json_decode($file);

foreach($data as $Idx => $key){
    if($key->Service->name === 'MySpace'){

        foreach($key->Metric as $Index => $Item){
            $ctr = 1;
            if($Index == "views"){
                foreach($Item as $a => $b){
                    $record[] = $b;
                }
            }

        }

    }

}

$year = array();
$price = array();
$year[] = 'Sun, 12 Feb 2012'; $price[] = 36.7;
$year[] = 'Sun, 13 Feb 2012'; $price[] = 38.7;
$year[] = 'Sun, 14 Feb 2012'; $price[] = 42.8;
$year[] = 'Sun, 15 Feb 2012'; $price[] = 38.2;
$year[] = 'Sun, 16 Feb 2012'; $price[] = 37.8;
$year[] = 'Sun, 17 Feb 2012'; $price[] = 34.7;
$year[] = 'Sun, 18 Feb 2012'; $price[] = 38.4;



$chart = new open_flash_chart();

$chart->set_bg_colour( '#FFFFFF' );

$title = new title( 'MySpace Views' );
$title->set_style( "{font-size: 20px; background:#fff; color: #A2ACBA; text-align: center; width: 300px; border-radius:50px;}" );
$chart->set_title( $title );

$area = new area();
$area->set_colour( '#5B56B6' );
$area->set_values( $record );
$area->set_key( 'Views', 7 );
$chart->add_element( $area );

$x_labels = new x_axis_labels();
$x_labels->set_steps( 1 );
//$x_labels->set_vertical();
$x_labels->set_colour( '#A2ACBA' );
$x_labels->set_labels( $year );

$x = new x_axis();
$x->set_colour( '#A2ACBA' );
$x->set_grid_colour( '#D7E4A3' );
$x->set_offset( false );
$x->set_steps(1);
$x->set_range('0','6');
// Add the X Axis Labels to the X Axis
$x->set_labels( $x_labels );

$chart->set_x_axis( $x );

//
// LOOK:
//
$x_legend = new x_legend( '2012' );
$x_legend->set_style( '{font-size: 20px; color: #778877}' );
$chart->set_x_legend( $x_legend );

//
// remove this when the Y Axis is smarter
//
$y = new y_axis();
$min = min($record);
$max = max($record);
$len = strlen($max);
if($len == '9'){
    $diff = '10000';
}elseif($len == '8'){
    $diff = '1000';
}elseif($len == '7'){
    $diff = '1000';
}elseif($len == '6'){
    $diff = '1000';
}elseif($len == '5'){
    $diff = '1000';
}

$y->set_range( $min, $max, $diff );
$chart->add_y_axis( $y );

echo $chart->toPrettyString();

Here is the print_r($data)

Array ( [0] => stdClass Object ( [Service] => stdClass Object ( [name] => MySpace [id] => 1 ) [Profile] => stdClass Object ( [url] => http://www.myspace.com/adamgreen1 [id] => 384 ) [Metric] => Array ( ) ) [1] => stdClass Object ( [Service] => stdClass Object ( [name] => Last.fm [id] => 2 ) [Profile] => stdClass Object ( [url] => http://www.last.fm/music/adam+green [id] => 174985 ) [Metric] => stdClass Object ( [plays] => stdClass Object ( [15383] => 10165386 [15384] => 10165386 [15385] => 10165375 [15386] => 10168408 [15387] => 10171611 [15388] => 10174725 [15389] => 10177797 ) [fans] => stdClass Object ( [15383] => 242392 [15384] => 242392 [15385] => 242535 [15386] => 242580 [15387] => 242641 [15388] => 242709 [15389] => 242775 ) [comments] => stdClass Object ( [15383] => 916 [15384] => 916 [15385] => 918 [15386] => 918 [15387] => 918 [15388] => 918 [15389] => 918 ) ) ) [2] => stdClass Object ( [Service] => stdClass Object ( [name] => Wikipedia [id] => 17 ) [Profile] => stdClass Object ( [url] => http://en.wikipedia.org/wiki/Adam_Green_(musician) [id] => 918802 ) [Metric] => Array ( ) ) ) 
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-30T08:53:34+00:00Added an answer on May 30, 2026 at 8:53 am

    Given that error, it would seem your php script is returning HTML in some cases, instead of json. That’s where you have to make the fix. If your Flash stuff is expecting ONLY json strings, then you cannot ever allow anything BUT json strings to be output from the script.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am using this function to close existing form and open a new form.
How can I ensure that this does NOT open in a new window?? onclick=ob=this.form.table;window.open(ob.options[ob.selectedIndex].value)/>
I'm new to this forum, but I've seen it a few times while trying
I am new to ASP.NET Someone in this forum helped me how to get
I am new to Chamilo 2.1, which is an open-source LMS. I initially posted
I'm new to this forum, and I have a question that has been bothering
I've posted this question in asp.net web forum but no one replied. I can't
I am new to this forum. I have a doubt about JSP/servlet in my
Please look at the image: This is a simple forum page. Anyone can open
I have a form to add new Appartments, and in this form I have

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.