Welcome to the Cumulus Support forum.

Latest Cumulus MX V4 release 4.4.2 (build 4085) - 12 March 2025

Latest Cumulus MX V3 release 3.28.6 (build 3283) - 21 March 2024

Legacy Cumulus 1 release 1.9.4 (build 1099) - 28 November 2014
(a patch is available for 1.9.4 build 1099 that extends the date range of drop-down menus to 2030)

Download the Software (Cumulus MX / Cumulus 1 and other related items) from the Wiki

If you are posting a new Topic about an error or if you need help PLEASE read this first viewtopic.php?p=164080#p164080

would like a new set of eyes on this

Other discussion about creating web sites for Cumulus that doesn't have a specific subforum

Moderator: daj

Post Reply
n9mfk
Posts: 845
Joined: Sun 10 May 2009 8:52 pm
Weather Station: davis vp2 Serial datalogger
Operating System: Windows 7 64-bit
Location: Springfield, IL

would like a new set of eyes on this

Post by n9mfk »

Hi I would like another set of eyes to look at this
it not ruining or send a error
http://n9mfk.info/newidea/test.php

Code: Select all

<?php
error_reporting(E_ALL);
ini_set("display_errors", 1);
//----------------------------------------------------------------------
// Generate JSON data for the Weather SteelSeries Gauges
// Author: Mark Crossley
//
// Ver 0.1 - 05/01/14 - Initial release, 0.X = a work in progress, breakages and changes on the fly likely! 
//----------------------------------------------------------------------
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program.  If not, see <http://www.gnu.org/licenses/>.
//----------------------------------------------------------------------

$RealtimeFilename = $_SERVER['DOCUMENT_ROOT'].'/cumuluswebtagsRealtime.php';  // realtime PHP variable file
$CurrentFilename = $_SERVER['DOCUMENT_ROOT'].'/cumuluswebtags.php';  // current PHP variable file

// set up the response headers
header('Cache-Control: private');
header('Cache-Control: no-cache, must-revalidate');
header('Content-type: text/json');

$response = decodeCumulus($CurrentFilename, $RealtimeFilename);

function decodeCumulus($currFile, $RealFile) {
   global $response $field1;
  // error_reporting(E_ALL);

   try {
      // incorporate all the Cumulus variables
      include($currFile);
      include($RealFile);

$field1 = "let see what we get";	  

    return array(array(
         
         $field1
         
		 
		 
		 ));
   
    
   
   
   } catch (Exception $e) {
      return $e->getMessage() . ' line:' . $e->getLine();
   }
}

// JSON encode the response
echo json_encode($response), "\n";
// all done!
?>
TNETWeather

Re: would like a new set of eyes on this

Post by TNETWeather »

Very hard to spot without debugging turned on...

Code: Select all

Parse error: syntax error, unexpected '$field1' (T_VARIABLE), expecting ',' or ';' in /www/vhosts/nweather/test/nntest1.php on line 35
that would be this line:

Code: Select all

global $response $field1;
Missing comma ...

I wouldn't not normally have a function defined in the middle of your main code either. (decodeCumulus)

Reformatted but un-testable by me since I don't have the files you are referencing:

Code: Select all

<?php
error_reporting(E_ALL);
ini_set("display_errors", 1);
//----------------------------------------------------------------------
// Generate JSON data for the Weather SteelSeries Gauges
// Author: Mark Crossley
//
// Ver 0.1 - 05/01/14 - Initial release, 0.X = a work in progress, 
// breakages and changes on the fly likely! 
//----------------------------------------------------------------------
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program.  If not, see <http://www.gnu.org/licenses/>.
//----------------------------------------------------------------------

  $RealtimeFilename   = $_SERVER['DOCUMENT_ROOT'] . 
    '/cumuluswebtagsRealtime.php';  // realtime PHP variable file
  $CurrentFilename    = $_SERVER['DOCUMENT_ROOT'].
    '/cumuluswebtags.php';  // current PHP variable file
  
  // set up the response headers
  header('Cache-Control: private');
  header('Cache-Control: no-cache, must-revalidate');
  header('Content-type: text/json');
  
  $response = decodeCumulus($CurrentFilename, $RealtimeFilename);

  // JSON encode the response
  echo json_encode($response), "\n";
  // all done!
  exit;

function decodeCumulus($currFile, $RealFile) {
  global $response, $field1;
  // error_reporting(E_ALL);

  try {
    // incorporate all the Cumulus variables
    include($currFile);
    include($RealFile);
    
    $field1 = "let see what we get";     
    
    return array(array($field1));
  } catch (Exception $e) {
    return $e->getMessage() . ' line:' . $e->getLine();
  }
}

?>
n9mfk
Posts: 845
Joined: Sun 10 May 2009 8:52 pm
Weather Station: davis vp2 Serial datalogger
Operating System: Windows 7 64-bit
Location: Springfield, IL

Re: would like a new set of eyes on this

Post by n9mfk »

Hi Kevin,
How did you see the error i was not see that on my page ?
what did i do wrong on the debugging?
Thanks Beau
TNETWeather

Re: would like a new set of eyes on this

Post by TNETWeather »

n9mfk wrote:Hi Kevin,
How did you see the error i was not see that on my page ?
what did i do wrong on the debugging?
Thanks Beau
I didn't, I put the code on my development server which has debugging turned on and looked for the syntax error I guessed would be there. I was right. That is the most common reason why you get no output when your server is configured for production and you have not turned on debugging.

How to do that really depends on what server you are using and what access you have to it.

Normally, I would turn them on in the .htaccess file of the site so I can see them, and then turn them off when I am done.

Code: Select all

php_flag  log_errors on
php_value error_log  /path_to_a_known_directory/PHP_errors.log
n9mfk
Posts: 845
Joined: Sun 10 May 2009 8:52 pm
Weather Station: davis vp2 Serial datalogger
Operating System: Windows 7 64-bit
Location: Springfield, IL

Re: would like a new set of eyes on this

Post by n9mfk »

Thanks Kevin,

is there A way i can get

Code: Select all

{"data":[["let see what we get"]]} 

Thanks Beau
TNETWeather

Re: would like a new set of eyes on this

Post by TNETWeather »

Not clear what you are trying to accomplish.

I don't have the tag files you have, so I have no way to see what the data is supposed to look like or what you are expecting it to look like.

Ref:
http://php.net/manual/en/function.json-encode.php
n9mfk
Posts: 845
Joined: Sun 10 May 2009 8:52 pm
Weather Station: davis vp2 Serial datalogger
Operating System: Windows 7 64-bit
Location: Springfield, IL

Re: would like a new set of eyes on this

Post by n9mfk »

some thing like this

Code: Select all

{"data":[["High Temperature","43.6&nbsp;&deg;F","2:21 PM","25.4&nbsp;&deg;F","1:33 PM"],["Low Temperature","15.1&nbsp;&deg;F","12:00 AM","-1.8&nbsp;&deg;F","7:22 AM"],["Temperature Range","28.5&nbsp;&deg;F","&nbsp;","27.2&nbsp;&deg;F","&nbsp;"],["High Apparent Temperature","37.7&nbsp;&deg;F","3:24 PM","18.0&nbsp;&deg;F","12:03 PM"],["Low Apparent Temperature","6.6&nbsp;&deg;F","12:04 AM","-8.3&nbsp;&deg;F","7:22 AM"],["Low Wind Chill","6.8&nbsp;&deg;F","12:04 AM","-7.4&nbsp;&deg;F","3:39 AM"],["High Heat Index","43.6&nbsp;&deg;F","2:21 PM","25.4&nbsp;&deg;F","1:33 PM"]]}
TNETWeather

Re: would like a new set of eyes on this

Post by TNETWeather »

Looks like the output from the Json command.

Is that what you are looking for? Again, not clear where you are heading or exactly what you are asking for.
n9mfk
Posts: 845
Joined: Sun 10 May 2009 8:52 pm
Weather Station: davis vp2 Serial datalogger
Operating System: Windows 7 64-bit
Location: Springfield, IL

Re: would like a new set of eyes on this

Post by n9mfk »

I am try to get the output like above using php
I have the data n9mfk.info/cumuluswebtags.php?view=source
but i can not get the correct format out of json_encode
thanks beau
TNETWeather

Re: would like a new set of eyes on this

Post by TNETWeather »

The script is attempting to load cumuluswebtagsRealtime.php which does not exist on your webserver or does not have the correct permission.

Code: Select all

$RealtimeFilename   = $_SERVER['DOCUMENT_ROOT'] . 
  '/cumuluswebtagsRealtime.php';  // realtime PHP variable file
$CurrentFilename    = $_SERVER['DOCUMENT_ROOT'].
  '/cumuluswebtags.php';  // current PHP variable file
And called in:

Code: Select all

$response = decodeCumulus($CurrentFilename, $RealtimeFilename);
TNETWeather

Re: would like a new set of eyes on this

Post by TNETWeather »

PM sent.
n9mfk
Posts: 845
Joined: Sun 10 May 2009 8:52 pm
Weather Station: davis vp2 Serial datalogger
Operating System: Windows 7 64-bit
Location: Springfield, IL

Re: would like a new set of eyes on this

Post by n9mfk »

got pm
sent pm
TNETWeather

Re: would like a new set of eyes on this

Post by TNETWeather »

Really should refer to the post with the original script in it...

https://cumulus.hosiene.co.uk/viewtopic.p ... geData.php

you have apparently stripped out most of the functional code which made it very confusing as to what you were trying to do.
Post Reply