MySQL -> JpGraph Interface

Hi
Have you replaced



function select_date($a, $b)
{
	if (!$b) {
		$d = date('d');
		$m = date('m');
		$y = date('Y');
	}
	foreach ($a as $a_key => $a_name) {
		if ($a_key == $b || $a_key == $y || $a_key == $m || $a_key == $d) {
			echo ' <option selected="selected" value="' . $a_key . '">' . $a_name .'</option>
					';
		} else {
			echo ' <option value="' . $a_key . '">' . $a_name . '</option>
					';
		}
	}
}


with


function select_date($a, $b)
{
	if (!$b) {
		$d = date('d');
		$m = date('m');
		$y = date('Y');
	}
	foreach ($a as $a_key => $a_name) {
		if ($a_key == $b || $a_key == $y || !is_numeric($a_name) &&  $a_key == $m || is_numeric($a_name) &&  $a_key == $d ) {
			echo ' <option selected="selected" value="' . $a_key . '">' . $a_name .
				'</option>
					';
		} else {
			echo ' <option value="' . $a_key . '">' . $a_name . '</option>
					';
		}
	}
}

in common_en.php?

:slight_smile: Krister

Hi Krister,
that did the trick. Many thanks for helping me out to continue using this excellent script.
Since we have to edit every new year, would it be an idea to modify the script according to changes made by Murry C. to the wxraindetail.php as per http://discourse.weather-watch.com/t/39306?
Many thanks, Dick

hi
replace

$year = array(2006 => 2006, 2007 => 2007, 2008 => 2008, 2009 => 2009, 2010 => 2010);

with

$startyear = '2006'; //Change to the year your data starts

$year[$startyear] = $startyear;
for ($i = $startyear; $i < date(Y); $i++) {
    $year[$i + 1] = ($i + 1);
}

in common_en.php

:slight_smile: Krister

Hi Krister, great stuff, works like a dream. Many thanks for yr. continued support.
Rgds
Dick

Any chance of getting a new .zip of this with any and all fixes and updates included in that .zip?

Thanks!

Does this work with the standard WD database format or do I have to create a new?

Hi Axel

It works with standard WDmySQL database.

Best regards,

Henrik

Thank’s Henrik

I cant get ant picture just an red x, all the setting seems to be correct.

Any idea what could be wrong?

A red X would indicate the image can’t be found.

What page you have this on?

Here is the url to the page http://www.axelvold.net/webpages/multiwx_en.php

and i know that an red x means that the image can’t be found :slight_smile:

Currently I get a similar error (shows alt text not graph) and I’ve not sorted it yet either! I dont have a page visible on the net though its on a local server.

Stuart

Well I sorted mine on my local server, I did not have the JPGraph font definition correct. So make sure you have this correct and if you dont have control over it them make sure the font (VERDANA) is actually installed on your host, if not use a different font in the multigraph.php script.

Stuart

Edit: Lars I just ran the multigraph.php script directly on your host and you do not have either the jpgraph path correct or you have not installed jpgraph, so fix that first.

I have jpgraph installed but now i get this error when accessing multigraph.php directly.

Warning: Wrong parameter count for min() in /mounted-storage/home46b/sub035/sc73389-BRUN/axelvold.net/multiwx/get_data.php on line 105

Warning: Wrong parameter count for max() in /mounted-storage/home46b/sub035/sc73389-BRUN/axelvold.net/multiwx/get_data.php on line 106
JpGraph Error Font file "H:/htdocs/jpgraph/fonts/verdana.ttf" is not readable or does not exist.

In which file is this defined,

H:/htdocs/jpgraph/fonts/verdana.ttf

?

I have that file on my server.

Well you have to configure the path to the fonts for JPGraph in a file called jpg-config.inc.php which is in the src directory, make it point at the directory containing the verdana ttf files.

I’d ignore the warning for now and see what happens.

Stuart

I have corrected the settings in jpg-config.ini.php

But now i get this error.

Warning: Wrong parameter count for min() in /mounted-storage/home46b/sub035/sc73389-BRUN/axelvold.net/multiwx/get_data.php on line 105

Warning: Wrong parameter count for max() in /mounted-storage/home46b/sub035/sc73389-BRUN/axelvold.net/multiwx/get_data.php on line 106
JpGraph Error: HTTP headers have already been sent.
Caused by output from file get_data.php at line 105. 
Explanation:
HTTP headers have already been sent back to the browser indicating the data as text before the library got a chance to send it's image HTTP header to this browser. This makes it impossible for the library to send back image data to the browser (since that would be interpretated as text by the browser and show up as junk text).
Most likely you have some text in your script before the call to Graph::Stroke(). If this texts gets sent back to the browser the browser will assume that all data is plain text. Look for any text, even spaces and newlines, that might have been sent back to the browser. 

For example it is a common mistake to leave a blank line before the opening "<?php".
 

Lars try opening multigraph.php and immediately after the <?php statement on the next line place

error_reporting(0);

and see what happens, the problem is being caused by the error message about min().

Stuart

Ok, i do get a picture but there is no data on it

Hi :smiley:
I have updated the script with all modifications on previous pages and a new and hopefully better MySql-query for date and time tables.

:slight_smile: Krister

Oops, i forgot to save the last changes #-o
If you already have installed it, replace:

    case 'yes':
        if ($field[2]) {
            $que1 = ("$data_1, $data_2, $data_3 FROM $table WHERE DATETIME $time_1 AND $data_1 and $data_2 and $data_3");
        } elseif ($field[1]) {
            $que1 = ("$data_1, $data_2 FROM $table WHERE DATETIME $time_1 AND $data_1 and $data_2");
        } elseif ($field[0]) {
            $que1 = ("$data_1 FROM $table WHERE DATETIME $time_1");
        } else {
            $que1 = ("Temperature FROM $table WHERE DATETIME <=NOW() and DATETIME>=DATE_SUB(NOW(), INTERVAL 24 hour)");
        }

        //Make a query
        //SELECT DATETIME, temperature FROM wx_data WHERE DATETIME BETWEEN '2008-03-16 00:00:00' AND '2008-03-16 23:59:59' AND DATETIME REGEXP '..:(00|10|20|30|40|50):..' AND temperature IS NOT NULL ORDER BY DATETIME ASC
        $sql = mysql_query("SELECT DATETIME, $que1 AND $data_1 IS NOT NULL ORDER BY DATETIME ASC") or
            die("getmysql error");
        break;

in get_data.php with:

    case 'yes':
        if ($field[2]) {
            $que1 = ("$data_1, $data_2, $data_3 FROM $table WHERE DATETIME $time_1 AND $data_1 and $data_2 and $data_3 IS NOT NULL");
        } elseif ($field[1]) {
            $que1 = ("$data_1, $data_2 FROM $table WHERE DATETIME $time_1 AND $data_1 and $data_2 IS NOT NULL");
        } elseif ($field[0]) {
            $que1 = ("$data_1 FROM $table WHERE DATETIME $time_1 AND $data_1 IS NOT NULL");
        } else {
            $que1 = ("Temperature FROM $table WHERE DATETIME <=NOW() and DATETIME>=DATE_SUB(NOW(), INTERVAL 24 hour)");
        }

        //Make a query
        //SELECT DATETIME, temperature FROM wx_data WHERE DATETIME BETWEEN '2008-03-16 00:00:00' AND '2008-03-16 23:59:59' AND DATETIME REGEXP '..:(00|10|20|30|40|50):..' AND temperature IS NOT NULL ORDER BY DATETIME ASC
        $sql = mysql_query("SELECT DATETIME, $que1 ORDER BY DATETIME ASC") or
            die("getmysql error");
        break;

Download from my signature below

Hi Krister

Thank you very much for the update of the script.

I have it up and running in:

www.silkeborg-vejret.dk/multigraf.php

Best regards,

Henrik

Hi

Excelent script ! Thanks Krister got it to work nicely

One question: How to get the text wider and spaces between the words
‘Compare Temperatures’
and
dates interval and the word ‘with’ – dates interval (see att)

I used

&nbsp;

to get the space in common_en
and widener the text in multi.css but no effects :oops:

thnxs !


multi_comp.png