Page 1 of 1

would like a new set of eyes on this

Posted: Fri 06 Feb 2015 9:59 pm
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!
?>

Re: would like a new set of eyes on this

Posted: Sat 07 Feb 2015 2:13 am
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();
  }
}

?>

Re: would like a new set of eyes on this

Posted: Sat 07 Feb 2015 2:25 am
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

Re: would like a new set of eyes on this

Posted: Sat 07 Feb 2015 2:33 am
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

Re: would like a new set of eyes on this

Posted: Sat 07 Feb 2015 2:42 am
by n9mfk
Thanks Kevin,

is there A way i can get

Code: Select all

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

Thanks Beau

Re: would like a new set of eyes on this

Posted: Sat 07 Feb 2015 3:05 am
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

Re: would like a new set of eyes on this

Posted: Sat 07 Feb 2015 4:00 am
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"]]}

Re: would like a new set of eyes on this

Posted: Sat 07 Feb 2015 5:55 am
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.

Re: would like a new set of eyes on this

Posted: Sat 07 Feb 2015 2:24 pm
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

Re: would like a new set of eyes on this

Posted: Sat 07 Feb 2015 7:00 pm
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);

Re: would like a new set of eyes on this

Posted: Sat 07 Feb 2015 7:03 pm
by TNETWeather
PM sent.

Re: would like a new set of eyes on this

Posted: Sat 07 Feb 2015 8:29 pm
by n9mfk
got pm
sent pm

Re: would like a new set of eyes on this

Posted: Sat 07 Feb 2015 10:29 pm
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.