PHP Enter the name of the winds according to the tag [wind0dir-act=endir:--]

All about the standard Meteobridge devices based on mobile routers from TP-Link, D-Link, ASUS

Moderator: Mattk

User avatar
wvdkuil
Platinum Boarder
Platinum Boarder
Posts: 606
Joined: Sun Jul 24, 2011 8:00 pm
Location: Belgium
Contact:

Re: PHP Enter the name of the winds according to the tag [wind0dir-act=endir:--]

Post by wvdkuil »

Cavaliere wrote: Sun Dec 18, 2022 1:39 pm I just tried your changes by renaming the Dashboard1.php file to Dashboard1.txt
only now on the page http://www.ombarcellonapg.com/saratoga/dashboard2.php , the dashboard.php file remains empty after I reload the template, is this normal? Do I need to make any changes?

can't see anything anymore why? Have I reloaded the model?

I also enclose the changes to the meteobridge below.
There are dozens of php errors in the script as all PHP code is now executed.
=> HTTP ERROR 500, meaning the script fails, the first one is at

Code: Select all

if(( $valore[th0temp-delta10] > 0.0 ) ){ $src = "trendUp.png"; }
<b>Fatal error</b>: Uncaught Error: Undefined constant &quot;th0temp&quot; in . . . .php:159
Stack trace:
#1 {main}
thrown in <b>/. . . .php</b> on line <b>159</b><br />

I cleaned the .txt file, it generates no php errors.Just try it and if it works, you can see the differences with your version.

Wim
Attachments
1234567.txt.zip
(2.49 KiB) Downloaded 96 times
Cavaliere
Junior Boarder
Junior Boarder
Posts: 26
Joined: Mon Dec 05, 2022 3:47 pm
Contact:

Re: PHP Enter the name of the winds according to the tag [wind0dir-act=endir:--]

Post by Cavaliere »

Thanks a lot for the help wim,

I've seen all the fixes you've made to the file, and now I'm trying it out and it seems to work for almost everything.

The temperature trend images do not appear, maybe because they are too big 250x250px?

Code: Select all

<?php
$valore = "th0temp-delta10";
if(( $valore > 0.0 ) ){ $src = "trendUp.png"; }
if(( $valore = 0.0 ) ){ $src = "trendNeutral.png"; }
if(( $valore < 0.0 ) ){ $src = "trendDown.png"; }		
?>
<img src="<?php echo $src; ?>" alt="" />		
I tried to correct the temperature trend tag like this, but it still doesn't work, the images are not visible (the images are in the same folder as the dashboard file):

Code: Select all

<div style="width:100px; height:30px; padding:5x; font-size:15px; margin:auto; padding-left: 20px; color: #FFFFFF;">[th0temp-delta10:--]&deg;C </div>
</td>
<?php
$valore = "[th0temp-delta10:--]";
if(( $valore > 0.0 ) ){ $src = "trendUp.png"; }
if(( $valore = 0.0 ) ){ $src = "trendNeutral.png"; }
if(( $valore < 0.0 ) ){ $src = "trendDown.png"; }		
?>
<img src="<?php echo $src; ?>" alt="" />
To avoid repeating php errors or in any case reading what the errors are, can I put a php string that you gave me a few days ago? but I can't find it anymore....and where to insert it? And sorry for the dumb question, how did you change the color inside the php script?
User avatar
wvdkuil
Platinum Boarder
Platinum Boarder
Posts: 606
Joined: Sun Jul 24, 2011 8:00 pm
Location: Belgium
Contact:

Re: PHP Enter the name of the winds according to the tag [wind0dir-act=endir:--]

Post by wvdkuil »

Cavaliere wrote: Sun Dec 18, 2022 2:54 pm . . .
To avoid repeating php errors or in any case reading what the errors are, can I put a php string that you gave me a few days ago? but I can't find it anymore....and where to insert it?
Use the attached code always at the beginning of a PHP script.
It allows two things:
  • display the php-source even when started in a browser
  • switch error reporting on by adding ?test at the url
You will see that similar code is in a lot of scripts, f.i. Saratoga-template sripts, all Leuven-template scripts, all PWS_Dashboard scripts.
This makes helping with debugging a lot easier.

Succes,
Wim

Code: Select all

<?php
if (isset($_REQUEST['sce']) && strtolower($_REQUEST['sce']) == 'view' ) {
   header('Pragma: public');
   header('Cache-Control: private');
   header('Cache-Control: no-cache, must-revalidate');
   header('Content-type: text/plain; charset=UTF-8');
   header('Accept-Ranges: bytes');
   header('Content-Length: '.filesize(__FILE__));
   header('Connection: close');
   readfile(__FILE__);
   exit;}
elseif (!isset ($_REQUEST['test'])) 
     {  ini_set('display_errors', 0);      error_reporting(0);}
else {  ini_set('display_errors', 'On');   error_reporting(E_ALL); }

?>
Attachments
before_all.txt.zip
(1.03 KiB) Downloaded 129 times
Last edited by wvdkuil on Sun Dec 18, 2022 5:37 pm, edited 3 times in total.
Cavaliere
Junior Boarder
Junior Boarder
Posts: 26
Joined: Mon Dec 05, 2022 3:47 pm
Contact:

Re: PHP Enter the name of the winds according to the tag [wind0dir-act=endir:--]

Post by Cavaliere »

Perfect, I inserted it before the table began, after the css part, but it could also be inserted before, to avoid some css code errors, since I'm inexperienced.

Now it doesn't report any errors, but I can't see any image in the temperature block why do you think?

http://www.ombarcellonapg.com/saratoga/dashboard2.php
User avatar
wvdkuil
Platinum Boarder
Platinum Boarder
Posts: 606
Joined: Sun Jul 24, 2011 8:00 pm
Location: Belgium
Contact:

Re: PHP Enter the name of the winds according to the tag [wind0dir-act=endir:--]

Post by wvdkuil »

1. Move the text for sce=view to the beginning of the file.
2. Typing error from me, remove all text after the ?>
Should look like this

Code: Select all

<?php
if (isset($_REQUEST['sce']) && strtolower($_REQUEST['sce']) == 'view' ) {
   header('Pragma: public');
   header('Cache-Control: private');
   header('Cache-Control: no-cache, must-revalidate');
   header('Content-type: text/plain; charset=UTF-8');
   header('Accept-Ranges: bytes');
   header('Content-Length: '.filesize(__FILE__));
   header('Connection: close');
   readfile(__FILE__);
   exit;}
elseif (!isset ($_REQUEST['test'])) 
     {  ini_set('display_errors', 0);      error_reporting(0);}
else {  ini_set('display_errors', 'On');   error_reporting(E_ALL); }
?>
3. The image is not displayed because the value is 0.0

Code: Select all

if(( $valore > 0.0 ) ){ $src = "trendUp.png"; }
if(( $valore = 0.0 ) ){ $src = "trendNeutral.png"; }
if(( $valore < 0.0 ) ){ $src = "trendDown.png"; }	
First line compares for greater
Last line compares for less
But the second line assigns a zero to $valore
Compare for equal uses ==

Code: Select all

if(  $valore == 0.0 )  { $src = "trendNeutral.png"; }
Also remove the xtra ( and ), they do nothing

Code: Select all

if ( $valore > 0.0 )  { $src = "trendUp.png"; }
if ( $valore == 0.0 ) { $src = "trendNeutral.png"; }
if ( $valore < 0.0 )  { $src = "trendDown.png"; }	
4. You have to add the width and height as the images are to big
Wim
Cavaliere
Junior Boarder
Junior Boarder
Posts: 26
Joined: Mon Dec 05, 2022 3:47 pm
Contact:

Re: PHP Enter the name of the winds according to the tag [wind0dir-act=endir:--]

Post by Cavaliere »

I made the modifications you indicated and I made these modifications, but the images are still not visible, why?

Code: Select all

<?php
$valore = "[th0temp-delta10:--]";
if( $valore > 0.0 )  { $src = "trendUp.png" ; }
if( $valore == 0.0 ) { $src = "trendNeutral.png"; }
if( $valore < 0.0 )  { $src = "trendDown.png"; }		
?>
<img src="<?php echo $src; ?>" width="30" height="30" />	
User avatar
wvdkuil
Platinum Boarder
Platinum Boarder
Posts: 606
Joined: Sun Jul 24, 2011 8:00 pm
Location: Belgium
Contact:

Re: PHP Enter the name of the winds according to the tag [wind0dir-act=endir:--]

Post by wvdkuil »

HTML problem: The img is not inside the <td> . . . </td>
The browser does not know what you want. It just skipped the <img. part.

Although web-browsers are very forgiving, they can not solve every language error.
When you validate your HTML the validator stops also at the <img>
https://validator.w3.org/nu/?doc=https: ... board2.php

Solutions:
1. Go step by step and and test between each step
2. Use a validator to check your html => https://validator.w3.org/
3. HTML is a language and as every new language you have to learn the basics
== Buy a book such as "HTML and CSS for Dummies" if it is available in Italian or
== HTML CSS: La guida completa al web design per progettare e sviluppare siti web in 7 giorni Copertina flessibile – 15 giugno
== Use the website https://html.com/
4. always test with different browsers, at least Chrome and FF.

If you want to build your own websites, you have to understand and use two new languages, HTML and PHP.
That takes time but it is a very interesting and rewarding hobby.

If you just want a small html/php page , find a IT-student who will be happy to do it for you for a small fee.

Succes, Wim
Attachments
checked.png
checked.png (487.48 KiB) Viewed 1529 times
Cavaliere
Junior Boarder
Junior Boarder
Posts: 26
Joined: Mon Dec 05, 2022 3:47 pm
Contact:

Re: PHP Enter the name of the winds according to the tag [wind0dir-act=endir:--]

Post by Cavaliere »

wvdkuil wrote: Mon Dec 19, 2022 10:20 am HTML problem: The img is not inside the <td> . . . </td>
The browser does not know what you want. It just skipped the <img. part.

Although web-browsers are very forgiving, they can not solve every language error.
When you validate your HTML the validator stops also at the <img>
https://validator.w3.org/nu/?doc=https: ... board2.php

Solutions:
1. Go step by step and and test between each step
2. Use a validator to check your html => https://validator.w3.org/
3. HTML is a language and as every new language you have to learn the basics
== Buy a book such as "HTML and CSS for Dummies" if it is available in Italian or
== HTML CSS: La guida completa al web design per progettare e sviluppare siti web in 7 giorni Copertina flessibile – 15 giugno
== Use the website https://html.com/
4. always test with different browsers, at least Chrome and FF.

If you want to build your own websites, you have to understand and use two new languages, HTML and PHP.
That takes time but it is a very interesting and rewarding hobby.

If you just want a small html/php page , find a IT-student who will be happy to do it for you for a small fee.

Succes, Wim
Ok thanks
Post Reply