473,396 Members | 2,115 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

Plotting mysql values in a dynamic image.

Hi folks,
Very much a learner when it comes to programming so excuse me if this is a silly question...
I'm trying to generate a map of the positions of moth records in a mysql database using PHP dynamic images.
I have managed to plot points by hand coding coordinates, however when I try to include an sql query to get coordinates, the image will not generate. I have tested the sql query on its own and it generates the appropriate output. If I simply embed the query into the code, but do not use the output of the query instead using inputted values the image does not generate. I can only assume that the query is causing a problem, but cannot find why.
Any advice would be much appreciated (code below)
Chris

<?php
header("Content-type: image/gif");
$image = imagecreatefrompng ("mapsize.png");
$red = imagecolorallocate($image, 255,0,0);

//Connect to mysql
INCLUDE("xxxx.php");

//Select gridrefs from dbase
$sql = "SELECT Gridref FROM moths2 WHERE Code=343";

$cursor = mysql_query($sql); if (!$cursor) { echo("<h3>SQL error: "
. mysql_error() ."<h3>"); exit(); }

while ($row = mysql_fetch_array($cursor) ) {

//Determine the number of coordinates in Grid ref, will sort out prefix later.
$aggri=$row["Gridref"];
$aggri1=strlen($aggri);

//if of form xx##
if ($aggri1=="4") { $xgrid=$aggri[3]; $ygrid=$aggri[4]; }
//if of form xx####
if ($aggri1=="6") { $xgrid=$aggri[3]*10; $ygrid=$aggri[5]*10; }
//if of form xx######
if ($aggri1=="8") { $xgrid=$aggri[3]; $ygrid=$aggri[6]; }
//if of form xx########
if ($aggri1=="10") { $xgrid=$aggri[3]; $ygrid=$aggri[7]; }

//Use positions to plot points on basemap
imagearc( $image, $xgrid,$ygrid, 5, 5, 0, 360, $red);
imagefill( $image, $xgrid,$ygrid, $red);

}
mysql_close( $dbh );
imagegif($image);
?>
Oct 2 '06 #1
2 2190
ronverdonk
4,258 Expert 4TB
Do a print_r($row) for each row right after the while and you'll see the data from your table. (if there are backslahes in it, assign the $aggri value using the stripslashes() command.). When you are then sure the data is correctly read from the db, you can inspect your handling code

Ronald :cool:
Oct 2 '06 #2
Thanks. It turned out to be the include call, which set the page to return as text conflicting with the call to create an image which thought it was producing a graphic.
Cheers!
Oct 2 '06 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

12
by: Russ | last post by:
I'm interested in setting up a web page where live data can be displayed in real-time on the web page. For example: I would like to display a (nice looking) graph of some data value versus time...
10
by: John Smith | last post by:
I know that uploading an image to a database has been covered, oh, about 3 trillion times. However, I haven't found anything covering uploading to a MySQL database with .net. Please don't...
1
by: wayne | last post by:
i want to plot a line graph. The values that I obtain are the RGB value of a TIFF image. i m plotting RGB values vs value(1,2,3..) so when generated the RGB values, there will b a column of values...
7
by: StupidScript | last post by:
>From the manual "Storage Requirements": "ENUM('value1','value2',...) =1 or 2 bytes, depending on the number of enumeration values (65,535 values maximum)" This seems to mean: "a" = 1 byte...
4
by: Gouri | last post by:
Hi, Got a query regarding plotting a preview / thumbnail for a graph which reads data from a binary file. The preview should should take very less time, look exactly like the original graph i.e....
6
Atli
by: Atli | last post by:
This is an easy to digest 12 step guide on basics of using MySQL. It's a great refresher for those who need it and it work's great for first time MySQL users. Anyone should be able to get...
2
archonmagnus
by: archonmagnus | last post by:
Hello all, I've been experimenting with developing an orbital analysis program. Being a visually oriented person, I'd like to translate my (x, y) coordinate pairs to an pixel image array so I can...
3
by: janetopps | last post by:
I have a news website, with asp pages, which was on Access, and i upgraded to MySQL, i used Bullzip to transfer the data. It had about 1000 pages, which im now able to pull up on the public side. Im...
1
ssnaik84
by: ssnaik84 | last post by:
Hi Guys, Last year I got a chance to work with R&D team, which was working on DB scripts conversion.. Though there is migration tool available, it converts only tables and constraints.. Rest of...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.