building Google Chart using php/mysql

340 views
Skip to first unread message

San Diran

unread,
Dec 25, 2013, 11:46:23 PM12/25/13
to google-visua...@googlegroups.com
Can anyone help me with this?  i want to plot number of people (death/alive/alive but disable) with sector.
New to everything, but will try my best to learn from anyone


chart.php
Statistic.php
database.png

asgallant

unread,
Dec 26, 2013, 11:12:53 AM12/26/13
to google-visua...@googlegroups.com
I skimmed over your code and it looks like it should work (assuming your statistic.php file's "content" section contains a div with the id "visualization").  What happens when you try to run it?  If you don't see a chart, open it in Chrome and view the developer's console (ctrl+shift+j opens it in Windows) - are there any error messages in the console?

San Diran

unread,
Dec 26, 2013, 12:32:44 PM12/26/13
to google-visua...@googlegroups.com
Firstly, thanks for replying

- yup, my content do have that div (<div id="visualization" style="width: 1000px; height: 400px;"></div>)
- receiving this "Uncaught SyntaxError: Unexpected token <" error msg
error.png

asgallant

unread,
Dec 26, 2013, 1:07:45 PM12/26/13
to google-visua...@googlegroups.com
It looks like your webserver is injecting HTML into the data returned by chart.php.  You have to disable the injection for the chart.php page.

San Diran

unread,
Dec 26, 2013, 1:18:06 PM12/26/13
to google-visua...@googlegroups.com
Not quite sure what you mean there..


--
You received this message because you are subscribed to a topic in the Google Groups "Google Visualization API" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/google-visualization-api/ANKJQlM24GA/unsubscribe.
To unsubscribe from this group and all its topics, send an email to google-visualizati...@googlegroups.com.
To post to this group, send email to google-visua...@googlegroups.com.
Visit this group at http://groups.google.com/group/google-visualization-api.
For more options, visit https://groups.google.com/groups/opt_out.

asgallant

unread,
Dec 26, 2013, 2:53:28 PM12/26/13
to google-visua...@googlegroups.com
According to the error message you posted, there is HTML inside the jsonData variable (you can see it in the output from console.log).  You need to figure out where that is coming from and get rid of it.  Since the chart.php code doesn't contain that HTML anywhere, I assume it is being injected via your webserver.


On Thursday, December 26, 2013 1:18:06 PM UTC-5, San Diran wrote:
Not quite sure what you mean there..
On Fri, Dec 27, 2013 at 2:07 AM, asgallant <drew_g...@abtassoc.com> wrote:
It looks like your webserver is injecting HTML into the data returned by chart.php.  You have to disable the injection for the chart.php page.


On Thursday, December 26, 2013 12:32:44 PM UTC-5, San Diran wrote:
Firstly, thanks for replying

- yup, my content do have that div (<div id="visualization" style="width: 1000px; height: 400px;"></div>)
- receiving this "Uncaught SyntaxError: Unexpected token <" error msg




On Friday, December 27, 2013 12:12:53 AM UTC+8, asgallant wrote:
I skimmed over your code and it looks like it should work (assuming your statistic.php file's "content" section contains a div with the id "visualization").  What happens when you try to run it?  If you don't see a chart, open it in Chrome and view the developer's console (ctrl+shift+j opens it in Windows) - are there any error messages in the console?

On Wednesday, December 25, 2013 11:46:23 PM UTC-5, San Diran wrote:
Can anyone help me with this?  i want to plot number of people (death/alive/alive but disable) with sector.
New to everything, but will try my best to learn from anyone


--
You received this message because you are subscribed to a topic in the Google Groups "Google Visualization API" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/google-visualization-api/ANKJQlM24GA/unsubscribe.
To unsubscribe from this group and all its topics, send an email to google-visualization-api+unsub...@googlegroups.com.

asgallant

unread,
Dec 26, 2013, 2:55:11 PM12/26/13
to google-visua...@googlegroups.com
I could be wrong about that - I took a closer look at the HTML, and it looks like it might be a PHP error message.  Open chart.php in a browser; what gets output?

San Diran

unread,
Dec 26, 2013, 10:34:09 PM12/26/13
to google-visua...@googlegroups.com
Sorry for the late reply, here is the pic from chart.php


To unsubscribe from this group and all its topics, send an email to google-visualizati...@googlegroups.com.
error.png

asgallant

unread,
Dec 27, 2013, 10:26:17 AM12/27/13
to google-visua...@googlegroups.com
That error pops up when you pass a boolean variable to mysql_fetch_assoc, which means $query is a not a resource.  mysql_query will return false if there is an error in the query, so you need to fix whatever the problem is.  You can get a hint of what that problem might be with this:

if (!$query){
    // you can read the error message by calling mysql_error()
    // do not output the contents of mysql_error to the browser in your production code!
    echo mysql_error();
}

On Thursday, December 26, 2013 10:34:09 PM UTC-5, San Diran wrote:
Sorry for the late reply, here is the pic from chart.php
On Fri, Dec 27, 2013 at 3:55 AM, asgallant <drew_g...@abtassoc.com> wrote:
I could be wrong about that - I took a closer look at the HTML, and it looks like it might be a PHP error message.  Open chart.php in a browser; what gets output?


On Thursday, December 26, 2013 2:53:28 PM UTC-5, asgallant wrote:
According to the error message you posted, there is HTML inside the jsonData variable (you can see it in the output from console.log).  You need to figure out where that is coming from and get rid of it.  Since the chart.php code doesn't contain that HTML anywhere, I assume it is being injected via your webserver.

On Thursday, December 26, 2013 1:18:06 PM UTC-5, San Diran wrote:
Not quite sure what you mean there..
On Fri, Dec 27, 2013 at 2:07 AM, asgallant <drew_g...@abtassoc.com> wrote:
It looks like your webserver is injecting HTML into the data returned by chart.php.  You have to disable the injection for the chart.php page.


On Thursday, December 26, 2013 12:32:44 PM UTC-5, San Diran wrote:
Firstly, thanks for replying

- yup, my content do have that div (<div id="visualization" style="width: 1000px; height: 400px;"></div>)
- receiving this "Uncaught SyntaxError: Unexpected token <" error msg




On Friday, December 27, 2013 12:12:53 AM UTC+8, asgallant wrote:
I skimmed over your code and it looks like it should work (assuming your statistic.php file's "content" section contains a div with the id "visualization").  What happens when you try to run it?  If you don't see a chart, open it in Chrome and view the developer's console (ctrl+shift+j opens it in Windows) - are there any error messages in the console?

On Wednesday, December 25, 2013 11:46:23 PM UTC-5, San Diran wrote:
Can anyone help me with this?  i want to plot number of people (death/alive/alive but disable) with sector.
New to everything, but will try my best to learn from anyone


--
You received this message because you are subscribed to a topic in the Google Groups "Google Visualization API" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/google-visualization-api/ANKJQlM24GA/unsubscribe.
To unsubscribe from this group and all its topics, send an email to google-visualization-api+unsubscr...@googlegroups.com.

To post to this group, send email to google-visua...@googlegroups.com.
Visit this group at http://groups.google.com/group/google-visualization-api.
For more options, visit https://groups.google.com/groups/opt_out.

San Diran

unread,
Dec 27, 2013, 11:22:43 AM12/27/13
to google-visua...@googlegroups.com
Thanks for the head up.. will try to solve it :)


To unsubscribe from this group and all its topics, send an email to google-visualizati...@googlegroups.com.

San Diran

unread,
Dec 27, 2013, 12:59:49 PM12/27/13
to google-visua...@googlegroups.com
Good day Asgallant,

Just wanna say thanks for all the helps, finally able to display my graph with desired data   :)
x1000 thumbs up for your teaching.. 

Reply all
Reply to author
Forward
0 new messages