Page 2 of 4

Re: Rolling Weekly Data - Displaying data on website

Posted: Mon 25 Apr 2022 9:07 am
by sfws
griffo42 wrote: Mon 25 Apr 2022 3:32 am I think that I have implemented the changes to my script that you suggested. A new Zipped copy is attached.
Actually, you did not add the error reporting I suggested. That would have been the most helpful change to have made.
That error reporting would identify if you have an error in statement for connecting to your database for example. You don't yet have a test to see if that works.

You wonder if it is your MySQL version, I doubt it.
I have not lodged the changes in MySQL by version in my memory. Your PHP 7 supports MySQL 5.1 and above, your screenshot from the phpMyAdmin home page shows your PHP has the "mysqli" component for MySQL 5.6, and it shows your database server is running 5.7, You could contact your host and get them to offer more up-to-date PHP components and MySQL components. Actually, it would be best if your host can offer you the latest stable PHP 8.1, and whatever is the latest stable database server.

The bulk of your script after the connect works as your query was tested with my PHP 8.1.14, my MariaDB 10.3.34, and my cumulus database.
Your database is fine, and the new error condition is not triggered.
There are no date handling bugs in the PHP 7.3.33 you are running, so the other change you did make has no effect.

You could simplify your while loop for any future test:

Code: Select all

while($row = $result->fetch_assoc()) {
echo "<th style='border-bottom:2px solid #8f8f8f;'>" . print_r($row) . "</th>";
}
and then you can see what the query does return, assuming the connection $conn is okay.

By the way, for a small file, you don't need to zip it, and readers then don't need to unzip it, just add a ".txt" extension (something like "7dcomphtitcumx.php.txt") and the forum will accept the file.

Re: Rolling Weekly Data - Displaying data on website

Posted: Mon 25 Apr 2022 9:29 am
by griffo42
Further to my previous I ran a query direct in PHPMyAdmin.
This is the query:
Screenshot 2022-04-25 190230Select Statement.png
This is the result:
Screenshot 2022-04-25 190430 select result.png
Keith

Re: Rolling Weekly Data - Displaying data on website

Posted: Mon 25 Apr 2022 9:35 am
by sfws
Of course the query works in phpMyAdmin, I said it was not the query in your script that is wrong.

My earlier answers covered my advice.

Re: Rolling Weekly Data - Displaying data on website

Posted: Tue 26 Apr 2022 6:05 am
by griffo42
@sfws

Thanks for your effort to try to sort this out for me. Much appreciated. I have posed the problem to my ISP and am presently awaiting its response.

Keith

Re: Rolling Weekly Data - Displaying data on website

Posted: Tue 26 Apr 2022 12:21 pm
by griffo42
@sfws
After quite some effort, I have now sorted tout the problem. It was largely related to including the database table in line 24. Once I deleted that, it basically fell out and worked. Again thanks for your help.

Keith

Re: Rolling Weekly Data - Displaying data on website

Posted: Sun 08 May 2022 12:11 pm
by AndyKF650
I have just set up this file and have managed to get it to work on my website. Since my mysql daydata db is only 1day old the data looks a bit odd but it is a start.

I tried to get it to run as a Cutils UserReport but for some reason it came up with a 2 Connection Failed" error however the same details worked cleanly on my local site. All very odd.

The working data can be seen on the Rolling Data test under the L'Alouette sites tab.

Re: Rolling Weekly Data - Displaying data on website

Posted: Thu 12 May 2022 2:00 pm
by AndyKF650
At last, after a steep learning curve with my network provider, I have managed to get this functionality working. Whilst HostPresto are good service providers their information for MySql newbie users is a bit thin.

I am quite pleased to have got CMX MySql talking to the host and once that happened I could get the .php to work as expected. I then sorted the style issues to get the end result looking similar to my website and then ended up with something I quite like. Certainly I need a few more days to make the 7 day data more meaningful but for now it is good.

Re: Rolling Weekly Data - Displaying data on website

Posted: Thu 12 May 2022 5:44 pm
by Mapantz
The 7 days average/trend of high and low pressure looks a bit suspect.. :lol:

Re: Rolling Weekly Data - Displaying data on website

Posted: Thu 12 May 2022 5:53 pm
by AndyKF650
Hi
Please note there is only 4 days data so the average is 4/7 hence looks odd

Re: Rolling Weekly Data - Displaying data on website

Posted: Thu 12 May 2022 7:34 pm
by Mapantz
Even if there was only one day of data, the pressure average wouldn't be that low?

Re: Rolling Weekly Data - Displaying data on website

Posted: Thu 12 May 2022 7:54 pm
by AndyKF650
Hi @mapanz

Having looked at the php file I can see that there is a method of getting the average correct with less than 7 days. Since I only have 5 days data on my daydata db by setting the correct days at the top of the file gives a better average.

I looked at your site and note that you have the current day showing, can I ask just how you achieved this since the dayfile is only updated at the end of the day. I assume that you are not using a version of the monthly file with data coming in every 5 mins or so.

Re: Rolling Weekly Data - Displaying data on website

Posted: Thu 12 May 2022 8:21 pm
by Mapantz
My CMX processes and uploads a file with my own custom PHP webtags, every 15 mins. That contains all of today's data.. :)

Re: Rolling Weekly Data - Displaying data on website

Posted: Fri 13 May 2022 5:24 am
by sfws
AndyKF650 wrote: Thu 12 May 2022 2:00 pm I am quite pleased to have got CMX Sql_connect talking to the host and once that happened I could get the .php to work as expected. .... Certainly I need a few more days to make the 7 day data more meaningful but for now it is good.
AndyKF650 wrote: Thu 12 May 2022 7:54 pm Since I only have 5 days data on my daydata db
Presumably you have realised, Mark's ExportToMySQL utility will populate past days onto your database table, using the same SQL_connect functionality as CMX, so you don't need to wait and wait to have the full 14 days available mentioned by original posting author for even that extreme right hand column to work as he designed?

A further bit of advice, in the early part of any day, including today in average calculations skews any parameter that typically has a diurnal pattern, as you are comparing say one hour or two of data for today (just part of variation pattern) with 24 hours worth of data (the full diurnal pattern) on other days. On my own site, where I do include "today" in means, I weight it by multiplying today's value by fractional number of hours in today, while values for other days are multiplied by 24, and then mean calculated by dividing by total number of hours included rather than number of days included, this gives a far more acceptable answer.

Re: Rolling Weekly Data - Displaying data on website

Posted: Fri 13 May 2022 6:39 am
by AndyKF650
Hi @sfws

Thanks for the advice and support on this issue, your information together with that of @mapantz hopefully will get this functionality working shortly.

Re: Rolling Weekly Data - Displaying data on website

Posted: Sat 14 May 2022 7:20 am
by AndyKF650
All done for now, Exporttomysql worked exactly as it says on the title with no problem.

Data is now falling into place and I think the page looks upto standard.