PHP Development
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me

The Shed is going Social! Join us on FaceBook and Twitter and chime in on the conversation.

Go Back   Dev Shed ForumsProgramming LanguagesPHP Development

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
  #1  
Old December 10th, 2012, 12:28 AM
jeremsp jeremsp is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Sep 2012
Posts: 7 jeremsp User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 1 h 20 m 19 sec
Reputation Power: 0
Error Encountered when using PHPlot to plot graph.

Hi, i am new to php. Any help will be much appreciated.

There is an error with the query although i do not know what to change to make it work.

Any ideas?

[php]
<?php
//Include the code
require_once 'phplot.php';
//Define the object
$plot = new PHPlot(800,600);
//Define some data

$dbhost = "localhost";
$username="root";
$password="";
$database="roy";


mysql_connect($dbhost,$username,$password);
@mysql_select_db($database) or die( "Unable to select database");

$query="SELECT * FROM try2";

$r = mysql_query($query);
if (!$r) exit();
$data = mysql_fetch_array();
$n_rows = mysql_fetch_row($r);
for ($i = 0; $i < $n_rows; $i++) $data[] = mysql_fetch_row($r, $i);


$plot->SetDataValues($data);

//Turn off X axis ticks and labels because they get in the way:
$plot->SetXTickLabelPos('none');
$plot->SetXTickPos('none');
//Draw it
$plot->DrawGraph();
?>
[php]

Reply With Quote
  #2  
Old December 10th, 2012, 07:56 AM
gw1500se gw1500se is online now
Contributing User
Dev Shed Frequenter (2500 - 2999 posts)
 
Join Date: Jul 2003
Posts: 2,879 gw1500se User rank is Colonel (50000 - 60000 Reputation Level)gw1500se User rank is Colonel (50000 - 60000 Reputation Level)gw1500se User rank is Colonel (50000 - 60000 Reputation Level)gw1500se User rank is Colonel (50000 - 60000 Reputation Level)gw1500se User rank is Colonel (50000 - 60000 Reputation Level)gw1500se User rank is Colonel (50000 - 60000 Reputation Level)gw1500se User rank is Colonel (50000 - 60000 Reputation Level)gw1500se User rank is Colonel (50000 - 60000 Reputation Level)gw1500se User rank is Colonel (50000 - 60000 Reputation Level)gw1500se User rank is Colonel (50000 - 60000 Reputation Level)gw1500se User rank is Colonel (50000 - 60000 Reputation Level)gw1500se User rank is Colonel (50000 - 60000 Reputation Level) 
Time spent in forums: 1 Year 2 Weeks 1 Day 11 h 31 m 21 sec
Reputation Power: 581
1) Please enclose your code in [ PHP ] tags. See the sticky at the top of this forum.
2) Don't use the depreciated MySQL extensions. You should be using PDO.
3) Since we are not clairvoyant, you will need to post the error message.
__________________
There are 10 kinds of people in the world. Those that understand binary and those that don't.

Reply With Quote
  #3  
Old December 10th, 2012, 11:23 AM
Jacques1's Avatar
Jacques1 Jacques1 is offline
pollyanna
Click here for more information.
 
Join Date: Jul 2012
Location: Germany
Posts: 1,867 Jacques1 User rank is Lieutenant General (80000 - 90000 Reputation Level)Jacques1 User rank is Lieutenant General (80000 - 90000 Reputation Level)Jacques1 User rank is Lieutenant General (80000 - 90000 Reputation Level)Jacques1 User rank is Lieutenant General (80000 - 90000 Reputation Level)Jacques1 User rank is Lieutenant General (80000 - 90000 Reputation Level)Jacques1 User rank is Lieutenant General (80000 - 90000 Reputation Level)Jacques1 User rank is Lieutenant General (80000 - 90000 Reputation Level)Jacques1 User rank is Lieutenant General (80000 - 90000 Reputation Level)Jacques1 User rank is Lieutenant General (80000 - 90000 Reputation Level)Jacques1 User rank is Lieutenant General (80000 - 90000 Reputation Level)Jacques1 User rank is Lieutenant General (80000 - 90000 Reputation Level)Jacques1 User rank is Lieutenant General (80000 - 90000 Reputation Level)Jacques1 User rank is Lieutenant General (80000 - 90000 Reputation Level)Jacques1 User rank is Lieutenant General (80000 - 90000 Reputation Level)Jacques1 User rank is Lieutenant General (80000 - 90000 Reputation Level) 
Time spent in forums: 1 Month 2 Weeks 1 Day 22 h 33 m 20 sec
Reputation Power: 813
Quote:
Originally Posted by gw1500se
2) Don't use the depreciated MySQL extensions. You should be using PDO.


Please, it's "deprecated". When I told you last time, you said it was a typo. But who makes the same typo every time he writes a word?

Reply With Quote
  #4  
Old December 10th, 2012, 11:45 AM
gw1500se gw1500se is online now
Contributing User
Dev Shed Frequenter (2500 - 2999 posts)
 
Join Date: Jul 2003
Posts: 2,879 gw1500se User rank is Colonel (50000 - 60000 Reputation Level)gw1500se User rank is Colonel (50000 - 60000 Reputation Level)gw1500se User rank is Colonel (50000 - 60000 Reputation Level)gw1500se User rank is Colonel (50000 - 60000 Reputation Level)gw1500se User rank is Colonel (50000 - 60000 Reputation Level)gw1500se User rank is Colonel (50000 - 60000 Reputation Level)gw1500se User rank is Colonel (50000 - 60000 Reputation Level)gw1500se User rank is Colonel (50000 - 60000 Reputation Level)gw1500se User rank is Colonel (50000 - 60000 Reputation Level)gw1500se User rank is Colonel (50000 - 60000 Reputation Level)gw1500se User rank is Colonel (50000 - 60000 Reputation Level)gw1500se User rank is Colonel (50000 - 60000 Reputation Level) 
Time spent in forums: 1 Year 2 Weeks 1 Day 11 h 31 m 21 sec
Reputation Power: 581
I do, obviously. Deprecate is a word I rarely use compared to depreciate so that is a natural typo for me. I don't know why I'm explaining myself to you anyway. Why are you so concerned with my typos in the first place? Is there anyone on this forum that you think is too dumb to understand what I meant?

Reply With Quote
  #5  
Old December 10th, 2012, 03:47 PM
paulh1983 paulh1983 is offline
Contributing User
Dev Shed Regular (2000 - 2499 posts)
 
Join Date: Dec 2004
Posts: 2,234 paulh1983 User rank is First Lieutenant (10000 - 20000 Reputation Level)paulh1983 User rank is First Lieutenant (10000 - 20000 Reputation Level)paulh1983 User rank is First Lieutenant (10000 - 20000 Reputation Level)paulh1983 User rank is First Lieutenant (10000 - 20000 Reputation Level)paulh1983 User rank is First Lieutenant (10000 - 20000 Reputation Level)paulh1983 User rank is First Lieutenant (10000 - 20000 Reputation Level)paulh1983 User rank is First Lieutenant (10000 - 20000 Reputation Level)paulh1983 User rank is First Lieutenant (10000 - 20000 Reputation Level) 
Time spent in forums: 2 Weeks 1 Day 10 h 37 m 56 sec
Reputation Power: 201
Quote:
Originally Posted by Jacques1
Please, it's "deprecated". When I told you last time, you said it was a typo. But who makes the same typo every time he writes a word?


...every time THEY write a word

If you are going to pick on someone, at least make sure your own grammar/English is acceptable or was that a typo?


PS> I am not having a go at you.

Reply With Quote
  #6  
Old December 10th, 2012, 03:54 PM
gw1500se gw1500se is online now
Contributing User
Dev Shed Frequenter (2500 - 2999 posts)
 
Join Date: Jul 2003
Posts: 2,879 gw1500se User rank is Colonel (50000 - 60000 Reputation Level)gw1500se User rank is Colonel (50000 - 60000 Reputation Level)gw1500se User rank is Colonel (50000 - 60000 Reputation Level)gw1500se User rank is Colonel (50000 - 60000 Reputation Level)gw1500se User rank is Colonel (50000 - 60000 Reputation Level)gw1500se User rank is Colonel (50000 - 60000 Reputation Level)gw1500se User rank is Colonel (50000 - 60000 Reputation Level)gw1500se User rank is Colonel (50000 - 60000 Reputation Level)gw1500se User rank is Colonel (50000 - 60000 Reputation Level)gw1500se User rank is Colonel (50000 - 60000 Reputation Level)gw1500se User rank is Colonel (50000 - 60000 Reputation Level)gw1500se User rank is Colonel (50000 - 60000 Reputation Level) 
Time spent in forums: 1 Year 2 Weeks 1 Day 11 h 31 m 21 sec
Reputation Power: 581
A special note to jeremsp. My apologies for being the vehicle through which someone decided to highjack your thread. Please resume your question.
Comments on this post
Jacques1 agrees: C'mon, don't be so thin-skinned.

Reply With Quote
  #7  
Old December 11th, 2012, 12:31 AM
jeremsp jeremsp is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Sep 2012
Posts: 7 jeremsp User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 1 h 20 m 19 sec
Reputation Power: 0
Hi I thought i have enclosed the code within the [PHP] tags.
Sorry if i made any mistakes quite new here.

The error of the query is


Warning: mysql_fetch_array() expects at least 1 parameter, 0 given in C:\xampp\htdocs\PHPlot\phplot-5.8.0\test1.php on line 21

Warning: mysql_fetch_row() [function.mysql-fetch-row]: The result type should be either MYSQL_NUM, MYSQL_ASSOC or MYSQL_BOTH in C:\xampp\htdocs\PHPlot\phplot-5.8.0\test1.php on line 23


and for the error on line 23 it just keep repeating until it cause lags and the window closes it. Did i loop it somewhere and cause it to repeat continuously? I really have no idea.

Reply With Quote
  #8  
Old December 11th, 2012, 03:23 AM
gw1500se gw1500se is online now
Contributing User
Dev Shed Frequenter (2500 - 2999 posts)
 
Join Date: Jul 2003
Posts: 2,879 gw1500se User rank is Colonel (50000 - 60000 Reputation Level)gw1500se User rank is Colonel (50000 - 60000 Reputation Level)gw1500se User rank is Colonel (50000 - 60000 Reputation Level)gw1500se User rank is Colonel (50000 - 60000 Reputation Level)gw1500se User rank is Colonel (50000 - 60000 Reputation Level)gw1500se User rank is Colonel (50000 - 60000 Reputation Level)gw1500se User rank is Colonel (50000 - 60000 Reputation Level)gw1500se User rank is Colonel (50000 - 60000 Reputation Level)gw1500se User rank is Colonel (50000 - 60000 Reputation Level)gw1500se User rank is Colonel (50000 - 60000 Reputation Level)gw1500se User rank is Colonel (50000 - 60000 Reputation Level)gw1500se User rank is Colonel (50000 - 60000 Reputation Level) 
Time spent in forums: 1 Year 2 Weeks 1 Day 11 h 31 m 21 sec
Reputation Power: 581
Untested but you replace all the obsolete MySQL stuff with this. You may need to reformat $data to get it the way you want.
PHP Code:
try {
   
$conn=new PDO("mysql:$dbhost;dbname=$database",$username,$password);
}
catch(
PDOException $e) {
   die(
"Unable to connect to database: ".$e->getMessage();
}
$query="SELECT * FROM try2";

$results=$conn->query($query);
if (
$results->rowCount()==0) exit();
$data=$results->fetchAll(); 

P.S. You forgot the '/' in your closing PHP tag.

Last edited by gw1500se : December 11th, 2012 at 03:31 AM.

Reply With Quote
  #9  
Old December 11th, 2012, 03:30 AM
jeremsp jeremsp is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Sep 2012
Posts: 7 jeremsp User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 1 h 20 m 19 sec
Reputation Power: 0
Hi. I have found a solution to the query and it works and a graph could be displayed.
PHP Code:
 $query="SELECT * FROM try1";
$result=mysql_query($query);

while(
$row=mysql_fetch_assoc($result)){
    
$data[]=$row;



By using this query it works.
Thank you all for your help.
Comments on this post
gw1500se disagrees: Again, don't use the MySQL extensions

Reply With Quote
Reply

Viewing: Dev Shed ForumsProgramming LanguagesPHP Development > Error Encountered when using PHPlot to plot graph.

Developer Shed Advertisers and Affiliates



Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump

Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 


Powered by: vBulletin Version 3.0.5
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.

© 2003-2013 by Developer Shed. All rights reserved. DS Cluster - Follow our Sitemap