cloudy

Author Topic: MySQL -> JpGraph Interface  (Read 30458 times)

0 Members and 2 Guests are viewing this topic.

Offline broadstairs

  • Stuart
  • Posts: 6,248
  • Broadstairs, Kent, UK
    • Broadstairs
Re: MySQL -> JpGraph Interface
« Reply #45 on: November 29, 2007, 09:38:21 PM »
I have proved that the error is caused by a session variable being set to NULL. I have recoded the part of the script the simple way by checking for null and if set then setting a value not used later and it all seems to work without the warning. It still needs some more testing though. If you dont see the warning then dont worry for now as your PHP installation obviously has the flags set which bypass this error (or its very old PHP!).

Stuart

Offline broadstairs

  • Stuart
  • Posts: 6,248
  • Broadstairs, Kent, UK
    • Broadstairs
Re: MySQL -> JpGraph Interface
« Reply #46 on: November 29, 2007, 10:09:11 PM »
One possible easy fix for this would be to change the session entries to be an array....  I've never tried this before...

Instead of doing...

$_SESSION["start"] = ($_POST["starty"] . "-" . $_POST["startm"] . "-" . $_POST["startd"] . " 00:00:00");
$_SESSION["end"] = ($_POST["endy"] . "-" . $_POST["endm"] . "-" . $_POST["endd"] . "23:59:59");
$_SESSION["group1"] = $_POST["group1"];
$_SESSION["fix_date"] = $_POST["fix_date"];


Do this instead:

$_SESSION["multiwx"]["start"] = ($_POST["starty"] . "-" . $_POST["startm"] . "-" . $_POST["startd"] . " 00:00:00");
$_SESSION["multiwx"]["end"] = ($_POST["endy"] . "-" . $_POST["endm"] . "-" . $_POST["endd"] . "23:59:59");
$_SESSION["multiwx"]["group1"] = $_POST["group1"];
$_SESSION["multiwx"]["fix_date"] = $_POST["fix_date"];


That way, the array passed to the session is never blank, as it is an array of other values...

This should work, though I've not tried it yet.  I have thought of doing this for something else, but for very different reasons.

Kevin it works as long as at least one value in the array is not NULL, if all array values are NULL we get the same warning  :( Just found out the hard way :(

Stuart

Online TNETWeather

  • Kevin Reed (KrelvinAZ)
  • Global Moderator
  • Posts: 5,865
  • Gremlins are at work...
  • Mesa, AZ
    • TNET Weather Station - Mesa AZ
Re: MySQL -> JpGraph Interface
« Reply #47 on: November 29, 2007, 10:22:15 PM »
Thats the part I wasn't sure of, but if you start off before you do anything by putting in a fixed number like:

$_SESSION["multiwx"]["multiwx"] = 1;

That wouldn't be an issue from then on I would think.

what if you used the data always via the full session name instead?

$_SESSION["start"]

Instead of

$start

I suspect the real issue is using the $_SESSION values as globals in the first place.

If you always refer to them as $_SESSION["variable"], it shouldn't be an issue, NULL or otherwise.



All you need is Time, Aptitude and Desire ... and you can build just about anything...

Offline broadstairs

  • Stuart
  • Posts: 6,248
  • Broadstairs, Kent, UK
    • Broadstairs
Re: MySQL -> JpGraph Interface
« Reply #48 on: November 29, 2007, 10:45:02 PM »
Well in this script it seems to be an issue, they are always referred to as $_SESSION["variable"] and if any is NULL then it gives the warning. I must admit in my scripts I've never used them for passing values between scripts, I always provide the parms for the script on the calling statement. That way I've never had a problem, and when all you are doing is passing data values I dont see any problems with security either. It would be different if you passed login values or passwords etc, that would be a disaster using my way.

This script wont work properly when V6 of PHP comes along, and it is no use to me with these problems in either. I have another data compare script I wrote about a year ago so I think I'll resurrect that.

Stuart

Offline kv-swe

  • Posts: 282
  • Sweden
    • Vädret i Hasslösa
Re: MySQL -> JpGraph Interface
« Reply #49 on: November 30, 2007, 08:41:37 PM »
Hi
Thanks for the improvement of the code  :)
I have modified the script so it works with PHP 5
I have tested it with error_reporting(E_ALL) on PHP v 5.2.3
configured like this: http://www.hasslosa.se/weather/files/phpinfo.htm
without errors (it does notice that nothing is selected when you open the page
<b>Notice</b>:  Undefined index:, but that dissapears when you create a graph)


 :) Krister
« Last Edit: January 11, 2008, 03:46:09 PM by kv-swe »

Offline jwwd

  • Posts: 3,561
  • Silkeborg, Denmark (56:10:58 N-09:30:26 E) - Elevation 75,35 meters
    • Weather at Silkeborg, Denmark
Re: MySQL -> JpGraph Interface
« Reply #50 on: December 11, 2007, 08:55:49 PM »
Hi Krister

I just discovered that y multigraph dont work anymore.

Im running PHP 4.4.7.

When I enter the page the temp graph last 24 hours loads ok. But if I try and create another grahp the same 24 hour temp grapf loads.

What do you think can be the problem?

See this link: www.buskelundtoften.dk/vejret/multigraf.php

Thanks

Best regards,

Henrik

Offline kv-swe

  • Posts: 282
  • Sweden
    • Vädret i Hasslösa
Re: MySQL -> JpGraph Interface
« Reply #51 on: December 11, 2007, 10:02:59 PM »
Hi Henrik

For some reason it has stopped working on your site, :( check that all paths and includes are correct 

 :) Krister

Offline jwwd

  • Posts: 3,561
  • Silkeborg, Denmark (56:10:58 N-09:30:26 E) - Elevation 75,35 meters
    • Weather at Silkeborg, Denmark
Re: MySQL -> JpGraph Interface
« Reply #52 on: December 12, 2007, 04:18:41 AM »
Hi Henrik
 :) Krister

Ooops - missed that 3 weeks ago.

I have gone thru all paths and includes - but cant figure out where the mistake are.

I have thought of starting all over - what version is working with PHP 4.4.7 ?

Best regards,

Henrik

Offline kv-swe

  • Posts: 282
  • Sweden
    • Vädret i Hasslösa
Re: MySQL -> JpGraph Interface
« Reply #53 on: December 12, 2007, 05:58:41 PM »
Hi Henrik
the last one i posted (v4) should work with both php4 and 5

 :) Krister

Offline jwwd

  • Posts: 3,561
  • Silkeborg, Denmark (56:10:58 N-09:30:26 E) - Elevation 75,35 meters
    • Weather at Silkeborg, Denmark
Re: MySQL -> JpGraph Interface
« Reply #54 on: December 12, 2007, 07:59:08 PM »
Hi again

I think I have it working now - but have a little problem - getting this error:

Warning: session_start() [function.session-start]: Cannot send session cache limiter - headers already sent (output started at E:\vhost\buskelundtoften.dk\httpdocs\vejret\top.php:11) in E:\vhost\buskelundtoften.dk\httpdocs\vejret\multiwx\common_en.php on line 2

See this link: www.buskelundtoften.dk/vejret/test.php

I have tried to remove the session_start(); in the common_en.php file - but then its not working.

What can be the problem?

Best regards,

Henrik

Online TNETWeather

  • Kevin Reed (KrelvinAZ)
  • Global Moderator
  • Posts: 5,865
  • Gremlins are at work...
  • Mesa, AZ
    • TNET Weather Station - Mesa AZ
Re: MySQL -> JpGraph Interface
« Reply #55 on: December 12, 2007, 08:10:55 PM »
Warning: session_start() [function.session-start]: Cannot send session cache limiter - headers already sent (output started at E:\vhost\buskelundtoften.dk\httpdocs\vejret\top.php:11) in E:\vhost\buskelundtoften.dk\httpdocs\vejret\multiwx\common_en.php on line 2

It means exactly what it is saying. 

You have already started sending content and are now attempting to send a new header.

It also tells you which line numbers the occurrence is happening in.

Look at:

E:\vhost\buskelundtoften.dk\httpdocs\vejret\top.php: line 11
E:\vhost\buskelundtoften.dk\httpdocs\vejret\multiwx\common_en.php line 2


Sometimes it could be a little as a space being sent.  So check to make sure you are not outputting spaces and other data before sending out the headers.

All you need is Time, Aptitude and Desire ... and you can build just about anything...

Offline jwwd

  • Posts: 3,561
  • Silkeborg, Denmark (56:10:58 N-09:30:26 E) - Elevation 75,35 meters
    • Weather at Silkeborg, Denmark
Re: MySQL -> JpGraph Interface
« Reply #56 on: December 12, 2007, 08:32:24 PM »
Hi Kevin

Thanks for your reply.

Hmm still not working. I have changed the link to: www.buskelundtoften.dk/vejret/multigraf.php

I have attached the 3 files that are included in the multigraf.php

I cant see where the dubble content is.

Thanks for your help.

Best regards,

Henrik

Online TNETWeather

  • Kevin Reed (KrelvinAZ)
  • Global Moderator
  • Posts: 5,865
  • Gremlins are at work...
  • Mesa, AZ
    • TNET Weather Station - Mesa AZ
Re: MySQL -> JpGraph Interface
« Reply #57 on: December 12, 2007, 09:01:38 PM »
1) why do you have two session_starts (one in multi-graph and one in common...)
2) What calls top.php, neither appears to have an include for it.

All you need is Time, Aptitude and Desire ... and you can build just about anything...

Offline jwwd

  • Posts: 3,561
  • Silkeborg, Denmark (56:10:58 N-09:30:26 E) - Elevation 75,35 meters
    • Weather at Silkeborg, Denmark
Re: MySQL -> JpGraph Interface
« Reply #58 on: December 12, 2007, 09:17:42 PM »
Hi again

I have now tried to remove the session in common_en.php but the error still is there.

www.buskelundtoften.dk/vejret/test.php is calling the top.php

Best regards,

Henrik

Online TNETWeather

  • Kevin Reed (KrelvinAZ)
  • Global Moderator
  • Posts: 5,865
  • Gremlins are at work...
  • Mesa, AZ
    • TNET Weather Station - Mesa AZ
Re: MySQL -> JpGraph Interface
« Reply #59 on: December 12, 2007, 09:28:53 PM »
Headers have to be sent before any other content, that includes your top.php file which includes all kinds of content...

If you want to start a session, you need to do that before any other output is sent to the visitor.

You have the session_start in multigraph which is after you call top.php to the error means what it is saying..

E:\vhost\buskelundtoften.dk\httpdocs\vejret\multiwx\common_en.php on line 2 is invalid because you already sent headers in top.php and other non-header info.

If you want to use sessions, you should have that done before anything else is sent.  You should also give them a name like:

session_name('unique_name');
session_start();


If you are using Web Developer add on in FF, you can actually see the session cookies and regular cookies with it.

All you need is Time, Aptitude and Desire ... and you can build just about anything...