Jump to content


Photo

Does Anyone Know What This Means?


  • Please log in to reply
8 replies to this topic

#1 j3rmain3

j3rmain3
  • Members
  • PipPipPip
  • Advanced Member
  • 40 posts

Posted 02 October 2006 - 09:33 AM

I am trying to display dynamic graphs using LibChart, PHP and MySQL. I not very sure whether i could use LibChart with MySQL so i am trying to find out but when i program it all in PHP i get this error, and have no idea what is means.

ERROR in query: Resource id #15.You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'Resource id #15' at line 1

Can anyone help?

J3rmain3

#2 steveclondon

steveclondon
  • Members
  • PipPipPip
  • Advanced Member
  • 161 posts

Posted 02 October 2006 - 09:36 AM

can you put some code up it will be a great help

#3 wildteen88

wildteen88
  • Staff Alumni
  • Advanced Member
  • 10,482 posts
  • LocationUK, Bournemouth

Posted 02 October 2006 - 09:36 AM

Looks like you are passing the wrong variable or something. Post your code here that corresponds to that error being returned.

#4 j3rmain3

j3rmain3
  • Members
  • PipPipPip
  • Advanced Member
  • 40 posts

Posted 02 October 2006 - 09:49 AM

Sorry about that.

Here is the coding

<html>
<head>
<title>Goals Per Game</title>
<h3>Goals Per Game</h3>
<meta http-equiv ="Content-Type" content="text/html; charset=ISO-8859-15" />
</head>
<body>

<?php

include "libchart/libchart/libchart.php";

$host = "localhost";
$user = "root";
$pass = "mysql";
$db = "goals";

$connection = mysql_connect($host,$user,$pass) or die ("Unable To Connect To Server"); #connect to server

mysql_select_db($db) or die ("Unable To Get Database"); #connect to database

$query = mysql_query("SELECT * FROM goals_data"); #select all fields from table

$result = mysql_query($query) or die ("ERROR in query: $query.".mysql_error());#run the query

$numplayers = mysql_num_rows($query);

#START CREATING THE CHART

$chart = new verticalChart();

for ($i=0; $i<=($query);$i++) {

$chart ->addPoint(new Point("f_name, $l_name", "$goals"));

}
$chart ->setTitle("Results From PowerDrive Field Test");
$chart ->render("graphs/powerDrive.png");

?>

<img alt="PowerDrive Report" src="graphs/PowerDrive.png" style="border: 1px solid black;" />

</body>
</html>

If you find more errors than just the problem i have stated can you please inform me. thery may be quite a bit because i was just choopping and adding things to try and get it to work

Thanks

J3rmain3


#5 steveclondon

steveclondon
  • Members
  • PipPipPip
  • Advanced Member
  • 161 posts

Posted 02 October 2006 - 09:52 AM

$numplayers = mysql_num_rows($query);

this should be

$numplayers = mysql_num_rows($result);

#6 j3rmain3

j3rmain3
  • Members
  • PipPipPip
  • Advanced Member
  • 40 posts

Posted 02 October 2006 - 09:58 AM

The error message still appears, and it still says the exact same thing.

J3rmain3

#7 steveclondon

steveclondon
  • Members
  • PipPipPip
  • Advanced Member
  • 161 posts

Posted 02 October 2006 - 10:00 AM

opps sorry didn't see that above.

$query = mysql_query("SELECT * FROM goals_data");

This should also be

$query = "SELECT * FROM goals_data";

#8 steveclondon

steveclondon
  • Members
  • PipPipPip
  • Advanced Member
  • 161 posts

Posted 02 October 2006 - 10:04 AM

You tryed to do the query twice. once using

$query = mysql_query("SELECT * FROM goals_data"); #select all fields from table

making $query the Resource result then you tried to query the database again with it which wouldn't work. Then you tried to count the rows with the $query instead of what will now be the $result. It wasn't failing on that bit at that time, however once you would have sorted that it would have failed there as well anyway.

$result = mysql_query($query) or die ("ERROR in query: $query.".mysql_error());#run the query


#9 j3rmain3

j3rmain3
  • Members
  • PipPipPip
  • Advanced Member
  • 40 posts

Posted 02 October 2006 - 10:05 AM

Yeah, i just realised that aswell

Thanks alot for the help

J3rmain3




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users