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 7547255
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T09:24:21+00:00 2026-05-30T09:24:21+00:00

I tried to populate google chart datatable in server side using PHP.I got JSON

  • 0

I tried to populate google chart datatable in server side using PHP.I got JSON file properply, but the Chart not display in client Application. I got error-Data column(s) for axis #0 cannot be of type string . My coding is below here.

After fetching data from database,

$colarray=array(array("id"=>"","label"=>"userid","pattern"=>"","type"=>"number"),array("id"=>"","label"=>"name","pattern"=>"","type"=>"string"));

  $final=array();
    for($i=0;$i<$rows;$i++) 
    {
     $id[$i]=pg_fetch_result($res1,$i,'id');
     $name[$i]=pg_fetch_result($res1,$i,'name');
     $prefinal[$i]=array("c"=>array(array("v"=>$name[$i]),array("v"=>$name[$i])));
     array_push($final,$prefinal[$i]);
    }


    $table['cols']=$colarray;
    $table['rows']=$final;
    echo json_encode($table);

My Output Json:

{
  "cols":[
    {"id":"","label":"userid","pattern":"","type":"number"},
    {"id":"","label":"name","pattern":"","type":"string"}
   ],
  "rows":[
    {"c":[{"v":"101"},{"v":"Aircel"}]},
    {"c":[{"v":"102"},{"v":"Srini"}]},
    {"c":[{"v":"103"},{"v":"Tamil"}]},
    {"c":[{"v":"104"},{"v":"Thiyagu"}]},
    {"c":[{"v":"105"},{"v":"Vasan"}]},
    {"c":[{"v":"107"},{"v":"Senthil"}]},
    {"c":[{"v":"108"},{"v":"Sri"}]},
    {"c":[{"v":"109"},{"v":"Docomo"}]},
    {"c":[{"v":"106"},{"v":"Innodea"}]}
    ]
}

How to solve this issue?

  • 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-30T09:24:22+00:00Added an answer on May 30, 2026 at 9:24 am

    You specify type of userid as number… but pass string.. thats causing the problem.

    I just wasted 30 mins with the opposite problem …

    Your output json should look like :-

    {
      "cols":[
        {"id":"","label":"userid","pattern":"","type":"number"},
        {"id":"","label":"name","pattern":"","type":"string"}
       ],
      "rows":[
        {"c":[{"v":101},{"v":"Aircel"}]},
        {"c":[{"v":102},{"v":"Srini"}]},
        {"c":[{"v":103},{"v":"Tamil"}]},
        {"c":[{"v":104},{"v":"Thiyagu"}]},
        {"c":[{"v":105},{"v":"Vasan"}]},
        {"c":[{"v":107},{"v":"Senthil"}]},
        {"c":[{"v":108},{"v":"Sri"}]},
        {"c":[{"v":109},{"v":"Docomo"}]},
        {"c":[{"v":106},{"v":"Innodea"}]}
        ]
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

For my Visualization Table, i populated data from server side using PHP as guided
Tried this: $('.link').click(function(e) { $.getScript('http://www.google.com/uds/api?file=uds.js&amp;v=1.0', function() { $('body').append('<p>GOOGLE API (UDS) is loaded</p>'); }); return
Tried examples from 'php.net' but don't understand what's the problem. Any suggestions? <?php $_SESSION['test']
As a beginner I tried to deserialize Google transliterator return array. It's a JSON
I tried doing something like: cmbMyBox.ListFillRange = E2 But the combobox does not seem
I'm trying to populate a DataTable, to build a LocalReport, using the following: MySqlCommand
I have a bunch of dropdownlists which I populate from an xml file using
I've tried a few different google searches but can't find any best practices or
I've tried everything Google and StackOverflow have recommended (that I could find) including using
Tried to map it from Preferences -> Settings -> Keyboard, but the key combo

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.