Page 3 of 7
Re: PHP script to display monthly/yearly snow depth totals from diary.db
Posted: Wed 18 Jan 2023 5:37 pm
by surban21
@PaulMy
I think I found the issue.
At the top of snowSumData.php for $myDbase enter the following if this the directory you're wanting to use:
$myDbase = 'sqlite:\KomokaWeather\CumulusMX\data\diary.db'; // <-- enter directory where diary.db located. DO NOT remove sqlite:
Then at the bottom of the same php file look for:
/* Writes the arrays to a text file to be called later from snowSummary.php Put this back when done testing
and for "file_put_contents" enter the direct path such as;
'C:\KomokaWeather\CumulusMX\webMX\snowSumDataT.txt'
This should get you running as it seemed to work for me. Good luck and let me know.
Re: PHP script to display monthly/yearly snow depth totals from diary.db
Posted: Wed 18 Jan 2023 9:16 pm
by PaulMy
Hi Steve,
Unfortunately after several hours not getting anywhere. I have tried it in two separate instances of CMX and just can't get it to produce a snowSumData.txt file. If have tried numerous differences in the snowSumData.php settings lines 31 and 157 to see if I could find the correct one but no luck. MXdiags says it is processing program, and have used php-win.exe and php.exe but the same result. I have checked the CumulusMX\data folder Properties and it has Read only ticked. When I change that and Save the next time looking at it it is again ticked Read only.
I tried to run it from Run as C:\Programs-Added\PHP\php-8.2.1-nts-Win32-vs16-x64\php.exe C:\KomokaWeather\CumulusMX\webMX\snowSumData.php
and it just flashes to a DOS screen without any info.
Also tried it from the DOS cmd (I really don't know how it all works, but just tried to follow similar to the Run for HansR Cumulusutils) and that shows:
Code: Select all
C:\>Programs-Added\PHP\php-8.2.1-nts-Win32-vs16-x64\php.exe C:\KomokaWeather\CumulusMX\webMX\snowSumData.php
Fatal error: Uncaught PDOException: could not find driver in C:\KomokaWeather\CumulusMX\webMX\snowSumData.php:39
Stack trace:
#0 C:\KomokaWeather\CumulusMX\webMX\snowSumData.php(39): PDO->__construct('sqlite:\\KomokaW...')
#1 {main}
thrown in C:\KomokaWeather\CumulusMX\webMX\snowSumData.php on line 39
and
Code: Select all
C:\>Programs-Added\PHP\php-8.2.1-nts-Win32-vs16-x64\php.exe C:\KomokaWeather\CumulusMXwll\webMX\snowSumData.php
Fatal error: Uncaught PDOException: could not find driver in C:\KomokaWeather\CumulusMXwll\webMX\snowSumData.php:39
Stack trace:
#0 C:\KomokaWeather\CumulusMXwll\webMX\snowSumData.php(39): PDO->__construct('sqlite:KomokaWe...')
#1 {main}
thrown in C:\KomokaWeather\CumulusMXwll\webMX\snowSumData.php on line 39
C:\>
Line 39 in snowSumData.php is
So presumably it can't find the \CumulusMX or \CumulusMXwll\data\diary.db but beyond me to fully understand and how to fix it
Any further thoughts, or suggestions to try?
Enjoy,
Paul
Re: PHP script to display monthly/yearly snow depth totals from diary.db
Posted: Wed 18 Jan 2023 9:37 pm
by surban21
@PaulMy
Out of curiosity check the php.ini file in the PHP folder that you installed. Inside the php.ini, do a search for sqlite and look for (extension=pdo_sqlite) and (extension=sqlite3). If either of these have a semi-colon (;) in front of them, remove only the semi-colons and save the ini file. This potentially could be the problem regarding the driver error. I seem to remember I had to remove these semi-colons.
Then continue with setting up my files per instructions like you have been doing.
Thanks for continuing to get my file to work.
Steve
Re: PHP script to display monthly/yearly snow depth totals from diary.db
Posted: Wed 18 Jan 2023 9:58 pm
by PaulMy
Thanks Steve,
Both had the semi-colon and I have removed them.
A step further but not yet there. This now the response in the CMD screen.
Code: Select all
C:\>C:\>Programs-Added\PHP\php-8.2.1-nts-Win32-vs16-x64\php.exe C:\KomokaWeather\CumulusMX\webMX\snowSumData.php
The process cannot access the file because it is being used by another process.
C:\>
I don't know which files it is referring to but have stopped both CMXs so that neither the External Programs nor CMX is accessing the \data or WebMX folders, and still the same message.
Enjoy,
Paul
Re: PHP script to display monthly/yearly snow depth totals from diary.db
Posted: Thu 19 Jan 2023 8:43 am
by Dador
Steve,
if I only check "Snow Falling" in the weather log, should one day be added in "Snow Events"?
Yesterday I had a snowfall, but no permanent snow cover. I marked it in my dairy, wrote it down. However, the script at the end of the day did not summarize the event.
Re: PHP script to display monthly/yearly snow depth totals from diary.db
Posted: Thu 19 Jan 2023 2:52 pm
by surban21
@Dador,
As of the way I understand diary.db, because of the way diary.db overwrites the snowDepth value if you enter a value more than once in a day, it will overwrite the previous value. For example, if this morning you enter 7.5 in the snow depth box inside the CMX weather diary editor and later that day you entered 2.5, it won't add it to the 7.5 already entered. Instead, it will replace the 7.5 with 2.5 for that day. Also diary.db only accepts number values in the snow depth entry in the weather diary editor.
All this to say, one must decide what they want to record for consistency. Either record snowfall only OR snow laying only. I found that using either of the snow falling or snow laying check boxes in the weather editor was of little use at this time and I did not incorporate them into my scripts. However, your question has given me an idea on how to possibly record non-measurable snow events as trace "T" and count it in the snow event days in my script. I will try utilizing the snow falling check box in the weather diary editor to be my trigger for a non-measurable snow event so that it would be counted as a snow event in my scripts.
As I mentioned on my first post, I'm unfortunately not a programmer and I'm figuring this stuff out as I go along. I've learned a lot by doing these scripts BUT I have so much more to learn and figure out how I can do things.
Now to directly answer your question, as of now my scripts are only able to count measurable snowfall as snow event days.
Thanks for your input Dador,
Steve
Re: PHP script to display monthly/yearly snow depth totals from diary.db
Posted: Thu 19 Jan 2023 4:27 pm
by Dador
Ok,
I'm glad you want to develop your script. I'll be following this thread and waiting for updates.
Good luck.
PS. If you plan to update the script quite often, you might want to consider extracting the translation file so that you don't have to enter it every time?
Re: PHP script to display monthly/yearly snow depth totals from diary.db
Posted: Fri 20 Jan 2023 12:58 pm
by surban21
Updated to ver 0.6
Now allows trace "T" snow recording. If no measurable snowfall for the day but it snowed then ONLY tick the Snow Falling checkbox in CMX and save. This will record the day as a snow event and will place a "T" in that month column unless or until there is measurable snowfall for that month. The snow event day tally will not be affected.
The download zip file is on the first page of this thread if you're interested.
Re: PHP script to display monthly/yearly snow depth totals from diary.db
Posted: Fri 20 Jan 2023 2:21 pm
by Dador
Everything works well.

Re: PHP script to display monthly/yearly snow depth totals from diary.db
Posted: Tue 24 Jan 2023 7:23 pm
by surban21
Now updated to ver 0.7 - 01-24-2023
New- added one decimal place after integer type numbers displaying snow depth values. ie; 3 now becomes 3.0
New- ability to set date format in user defined area inside snowSumData.php
New- ability to set decimal type (comma or period) in user defined area of snowSumData.php
Fixed- snowSumData.php sql's lastSnow and firstSnow in northern hemisphere to read concatenated years properly.
The zip file can be downloaded from the first post on this thread. Thanks
Re: PHP script to display monthly/yearly snow depth totals from diary.db
Posted: Thu 26 Jan 2023 12:35 pm
by Dador
Hi Steve,
what do you think about this idea?
Re: PHP script to display monthly/yearly snow depth totals from diary.db
Posted: Thu 26 Jan 2023 10:09 pm
by surban21
Daniel,
I've already been tossing this around. Good call

I'll play around with it and see about incorporating this.
Steve
Re: PHP script to display monthly/yearly snow depth totals from diary.db
Posted: Sat 28 Jan 2023 4:59 pm
by surban21
Updated to ver 0.8 - 01-28-2023
ver 0.8
New- added totals in the html table, "Snowfall Depths each Month Summed Over All Years"
Fixed- problem when entering data on 31st of month putting value in following month. Fixed in sql query in snowSumData.php.
The zip file can be downloaded from the first post on this thread
Re: PHP script to display monthly/yearly snow depth totals from diary.db
Posted: Fri 24 Feb 2023 9:26 pm
by surban21
Updated to ver 0.9 - 02-24-2023
ver 0.9
- New- re-wrote large portion of the code to incorporate using the SnowLying check box in CMX to count the amount of days that snow is on the ground. ie; snowpack or ground cover.
- New- modified the table row highlighter to work properly due to now having a rowspan of 3 for each year
- Advisory- For those that have already installed my previous scripts, you will need to install all version 0.9 scripts except for snowSumData.txt. You will not loose any data.
The zip file can be downloaded from the first post on this thread
Re: PHP script to display monthly/yearly snow depth totals from diary.db
Posted: Sat 25 Feb 2023 12:41 pm
by Dador
Hi Steve,
I see you've put some effort into writing the code. Lots of changes, but for the better. It's clearer now. Good job.
