dev-ria Posted October 12, 2012 Share Posted October 12, 2012 i am using jpgraph and im trying to run a query to create a pie chart. when i run the query the graph wont appear and when i run the graph first the query wont run. what am i missing here? here is what it looks like. http://semesterold.com/code2.html Quote Link to comment https://forums.phpfreaks.com/topic/269386-why-wont-my-query-run/ Share on other sites More sharing options...
premiso Posted October 12, 2012 Share Posted October 12, 2012 I would try and debug your query: $query = mysql_query(" SELECT domain, COUNT(domain) AS domaincount FROM domaindata WHERE email_sent_date = '' GROUP BY domain") or trigger_error(mysql_error()); Should tell you if your query is bad etc. See what that says and report back. Quote Link to comment https://forums.phpfreaks.com/topic/269386-why-wont-my-query-run/#findComment-1384771 Share on other sites More sharing options...
dev-ria Posted October 12, 2012 Author Share Posted October 12, 2012 (edited) ive tried that....when the graph runs first it displays the graph but wont run the query part...and when query runs i get results but not the graph. i'm trying to figure whats prevent it from running everything. there error i get when i run query first is this. ( ! ) Notice: in C:\wamp\www\jpgraph\test.php on line 18 Call Stack # Time Memory Function Location 1 0.0041 685928 {main}( ) ..\test.php:0 2 0.0410 7442184 trigger_error ( ) ..\test.php:18 when graph goes first i get no errors Edited October 12, 2012 by dev-ria Quote Link to comment https://forums.phpfreaks.com/topic/269386-why-wont-my-query-run/#findComment-1384774 Share on other sites More sharing options...
Jessica Posted October 12, 2012 Share Posted October 12, 2012 Are you sure you're connected to mysql? Quote Link to comment https://forums.phpfreaks.com/topic/269386-why-wont-my-query-run/#findComment-1384776 Share on other sites More sharing options...
dev-ria Posted October 12, 2012 Author Share Posted October 12, 2012 yes, because when i remove the graph code i get all my results of the query.....so im 100% both codes are running properly (separated) but they wont run on one page. I think that because the code exits at the end of each run it wont run the next code....so when the graph goes first....it will run and then exit at the end so it wont run the query code Quote Link to comment https://forums.phpfreaks.com/topic/269386-why-wont-my-query-run/#findComment-1384779 Share on other sites More sharing options...
Jessica Posted October 12, 2012 Share Posted October 12, 2012 I don't see any attempt to actually display the graph. Quote Link to comment https://forums.phpfreaks.com/topic/269386-why-wont-my-query-run/#findComment-1384782 Share on other sites More sharing options...
jcbones Posted October 12, 2012 Share Posted October 12, 2012 You cannot use an image header on any page you wish to echo text to. That must be done on a different page. When you send something with the header content as an image, then the whole document is treated and interpreted as an image. PHP's default header content type is 'text/html', that is why you don't have to set it for a regular page. If we had a clearer understanding of what you are trying to do, we could walk you through it. Quote Link to comment https://forums.phpfreaks.com/topic/269386-why-wont-my-query-run/#findComment-1384793 Share on other sites More sharing options...
dev-ria Posted October 12, 2012 Author Share Posted October 12, 2012 ah that makes sense....well what i am trying to do is use the mysql data to create a pie graph. So i am running a query to get the data then putting the data in the $data = array(stuff from query) so that i can display it on the graph. how can i run the query if i cant have anything on this page? Quote Link to comment https://forums.phpfreaks.com/topic/269386-why-wont-my-query-run/#findComment-1384802 Share on other sites More sharing options...
jcbones Posted October 12, 2012 Share Posted October 12, 2012 You can have queries in the page, you just can't echo the results. The results must be sent to the image generator. So, if you want the query in the data variable. $query = mysql_query(" SELECT domain, COUNT(domain) AS domaincount FROM domaindata WHERE email_sent_date = '' GROUP BY domain"); while($run = mysql_fetch_array($query)) { $data[] = $run['domaincount']; } is the date_email_sent really suppose to be blank? Quote Link to comment https://forums.phpfreaks.com/topic/269386-why-wont-my-query-run/#findComment-1384828 Share on other sites More sharing options...
dev-ria Posted October 12, 2012 Author Share Posted October 12, 2012 ah i see! yes the date email is supposed to be blank. basically selecting all the date fields that are empty because if they are empty i need to see which domains Quote Link to comment https://forums.phpfreaks.com/topic/269386-why-wont-my-query-run/#findComment-1384830 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.