WXforum.net
Web Weather => Weather Website PHP/AJAX scripting => Topic started by: cirrus on January 02, 2017, 05:26:22 AM
-
Hello Ken!,
Just thought I'd give you a heads up that the Atom Warnings throws illegal string warnings on the array using PHP 7.1 ... reverted back to PHP 7.0 and all is well.
Example of PHP 7.1 errors when running nws-alerts.php:
Warning: A non-numeric value encountered in /home/rkcrk201/public_html/nws-alerts.php on line 127
Warning: Illegal string offset 'Central Col. R. Gorge, OR' in /home/rkcrk201/public_html/nws-alerts.php on line 219
Warning: Illegal string offset 'N. OR Cascades' in /home/rkcrk201/public_html/nws-alerts.php on line 219
Warning: Illegal string offset 'S. WA Cascades' in /home/rkcrk201/public_html/nws-alerts.php on line 219
Warning: Illegal string offset 'W. Col. R. Gorge, OR' in /home/rkcrk201/public_html/nws-alerts.php on line 219
Warning: Illegal string offset 'ORZ041' in /home/rkcrk201/public_html/nws-alerts.php on line 308
Fatal error: Uncaught Error: Cannot use string offset as an array in /home/rkcrk201/public_html/nws-alerts.php:308 Stack trace: #0 {main} thrown in /home/rkcrk201/public_html/nws-alerts.php on line 308
Best Regards,
-Kevin
-
www.pennlake.us
I'm using 7.1 and I don't seem to be having any issues.
yamiacaveman
-
www.pennlake.us
I'm using 7.1 and I don't seem to be having any issues.
yamiacaveman
How many NWS alert zones are you using? I'm using 8 zones with cron to run nws-alerts.php
-
I am using 10 well 11 I have my town listed separately but I also have an alert for my county, which of-course my town is in, running a cron job on the server.
-
Okay thanks...I don't know why the php 7.1 version on mine throws errors but my 7.0 version is fine... hopefully Ken can help
-
I wish I could help you out more but I haven't a clue. I am also running the Meteotemplate and that works fine also in 7.1
-
Hello Ken!,
Just thought I'd give you a heads up that the Atom Warnings throws illegal string warnings on the array using PHP 7.1 ... reverted back to PHP 7.0 and all is well.
Example of PHP 7.1 errors when running nws-alerts.php:
Warning: A non-numeric value encountered in /home/rkcrk201/public_html/nws-alerts.php on line 127
Warning: Illegal string offset 'Central Col. R. Gorge, OR' in /home/rkcrk201/public_html/nws-alerts.php on line 219
Warning: Illegal string offset 'N. OR Cascades' in /home/rkcrk201/public_html/nws-alerts.php on line 219
Warning: Illegal string offset 'S. WA Cascades' in /home/rkcrk201/public_html/nws-alerts.php on line 219
Warning: Illegal string offset 'W. Col. R. Gorge, OR' in /home/rkcrk201/public_html/nws-alerts.php on line 219
Warning: Illegal string offset 'ORZ041' in /home/rkcrk201/public_html/nws-alerts.php on line 308
Fatal error: Uncaught Error: Cannot use string offset as an array in /home/rkcrk201/public_html/nws-alerts.php:308 Stack trace: #0 {main} thrown in /home/rkcrk201/public_html/nws-alerts.php on line 308
Best Regards,
-Kevin
that is very odd. I'm still in Illinois so access to my debugging tools is limited. I did download a copy of your nws-alerts.php and it appears to match with the current version (minus one comment line).
Looking at the errors reported, the line 127 error is in $cmyzc += substr_count($myv, '|'); // total count of codes in $myZC array
which is valid syntax for the substr_count() function.
The line 219 errors are in $noAlrt[$nk] = $nv[0];
which should be alright if $noAlrt was previously declared to be an array(). On line 103, it is declared as a string by $noAlrt = '';
so should probably be $noAlrt = array();
to avoid that type conversion. Similarly:
The line 308 errors are in $ad[$lCode][] = array($event,$urgency,$severity,$certainty,$effective,$expires,
$areaDesc,$instruction,$description,$clr,$ico,$sev,$cvk,$WA,$cvv[0],$poly,$ck);
which (again) should be ok if $ad has been previously declared to be an array() .. unfortunately, that was declared $ad = '';
on line 101. It should likely be $ad = array();
-
Try removing the periods and commas in the locations.
-
The likely issue is with the php 7.1 handling of arrays.
php 7.0 made some changes in array handling. php 7.1 has made further significant changes to array handling.
http://php.net/manual/en/migration71.incompatible.php
Of interest is;
The empty index operator is not supported for strings anymore
Applying the empty index operator to a string (e.g. $str[] = $x) throws a fatal error instead of converting silently to array.
-
I've made the two changes per Kens recommendations.
You can download the single file here:
http://www.weather.ricksturf.com/scripts/nws-alerts_138.zip
-
I've made the two changes per Kens recommendations.
You can download the single file here:
http://www.weather.ricksturf.com/scripts/nws-alerts_138.zip
Hi Curly,
Tried it out on 7.1 but it produced errors;
Warning: A non-numeric value encountered in /home/rkcrk201/public_html/nws-alerts.php on line 128
Warning: Illegal string offset 'ORC065' in /home/rkcrk201/public_html/nws-alerts.php on line 327
Warning: Illegal string offset 'ORC065' in /home/rkcrk201/public_html/nws-alerts.php on line 327
Warning: Illegal string offset 'ORC065' in /home/rkcrk201/public_html/nws-alerts.php on line 327
Warning: Illegal string offset 'ORC065' in /home/rkcrk201/public_html/nws-alerts.php on line 327
Warning: Illegal string offset 'ORZ510' in /home/rkcrk201/public_html/nws-alerts.php on line 327
Warning: Illegal string offset 'WAZ521' in /home/rkcrk201/public_html/nws-alerts.php on line 327
Warning: Invalid argument supplied for foreach() in /home/rkcrk201/public_html/nws-alerts.php on line 371
Warning: array_keys() expects parameter 1 to be array, null given in /home/rkcrk201/public_html/nws-alerts.php on line 391
Warning: array_shift() expects parameter 1 to be array, null given in /home/rkcrk201/public_html/nws-alerts.php on line 392
Warning: Invalid argument supplied for foreach() in /home/rkcrk201/public_html/nws-alerts.php on line 473
Warning: Invalid argument supplied for foreach() in /home/rkcrk201/public_html/nws-alerts.php on line 518
Warning: Invalid argument supplied for foreach() in /home/rkcrk201/public_html/nws-alerts.php on line 599
Warning: A non-numeric value encountered in /home/rkcrk201/public_html/nws-alerts.php on line 1088
Works fine on 7.0 though
Regards,
-Kevin
-
Tried it out on 7.1 but it produced errors;
Have you tried it with the commas removed from the locations?
-
Tried it out on 7.1 but it produced errors;
Have you tried it with the commas removed from the locations?
Curly,
I tried that with and without your nws-alerts.php mods and nws-alerts.php nor index.php would load at all.
Regards,
-Kevin
-
Ok -- Now it's my turn -- Had to switch back to PHP 7.0 for the alerts to work.
Is there a resolution to this problem? No problem if not, I'll just stay at 7.0 for now
-
So -- This is what I get in the Alert box instead of the warning: Well let me say this the alert part works but when I go to the specific County I get the stuff below.
Fatal error: Uncaught Error: [] operator not supported for strings in /home/pennla7/public_html/nws-alerts-details-inc.php:137 Stack trace: #0 /home/pennla7/public_html/wxnws-details.php(52): include() #1 {main} thrown in /home/pennla7/public_html/nws-alerts-details-inc.php on line 137
-
As soon as I have access to ver 7.1, I'll get to work on a fix.
-
Hi Curly,
Like I said no hurry or problem for me, switching back to 7.0 is easy.
Just wanted to let someone know: Funny, it worked up until today - I wonder what changed today??
Thanks
-
The errors are fixed for php ver 7.1.
Two non-configurable files were changed:
nws-alerts.php
nws-alerts-details-inc.php
http://www.weather.ricksturf.com/wxScripts.php
-
Thanks Curly,
I updated those two files and went up to 7.1
I won't have the ability to check on it today, but it seems to work now, and I will check on it when I can.
Thanks and thanks to ricksturf!
-
Not working on PHP 7.1.1 any updates
-
'Not working' is a bit vague to diagnose a problem.
What is the URL to the page(s) not working?
What are the PHP error messages shown?
-
Sorry sir it was early when i posted this. I downloaded the above file and it took most of the errors away but these two
Warning: A non-numeric value encountered in C:\xampp\htdocs\weather\nws-alerts.php on line 128
Warning: A non-numeric value encountered in C:\xampp\htdocs\weather\nws-alerts.php on line 1088
my site is http://westsenecaweather.com
-
Thanks!
Looking at check-fetch-times.php?show=versions on your site shows you have a few template scripts to update (just not nws-alerts.php ;) )
The Line 128 error is in the middle line of foreach ($myZC as $myv) {
$cmyzc += substr_count($myv, '|'); // total count of codes in $myZC array
}
and $myZC comes from if(isset ($SITE['NWSalertsCodes'])) {$myZC = $SITE['NWSalertsCodes'];}
and your Settings.php has $SITE['NWSalertsCodes'] = array(
"Cattaraugus|NYC009",
"Chautauqua|NYC013",
"Erie|NYC029",
);
The error message may be caused by nws-alerts.php $cmyzc = '';
which initializes the $cmyzc as a null string. Try changing that to $cmyzc = 0;
which would cast it as an integer instead. Maybe PHP 7.1 is more fussy about variable typing.
For the other error at line 1088 which is the second line in $total_times = '';
$total_times += ($time_stopTotal - $time_startTotal);
try changing that to $total_times = 0;
$total_times += ($time_stopTotal - $time_startTotal);
for the same reason.
-
This one just poped up Fatal error: Uncaught Error: [] operator not supported for strings in C:\xampp\htdocs\weather\nws-alerts.php:307 Stack trace: #0 C:\xampp\htdocs\weather\header.php(41): include_once() #1 C:\xampp\htdocs\weather\index.php(43): include('C:\\xampp\\htdocs...') #2 {main} thrown in C:\xampp\htdocs\weather\nws-alerts.php on line 307
-
That's code
(isset($abbrvd[1])) ? $abbrvDesc = $abbrvd[1] : $abbrvDesc = '';
$logData[] = array($event,$cvk,$effective,$expires,$cis['icon'],$areaDesc,$abbrvDesc);
and it's caused by $logData = '';
which should be $logData = array();
Try that change...
-
php version 7.1 gives this error when there is a Warning appears to run when no warnings are present?? Have made the changes in this thread to no avail.
Warning: Illegal string offset 'WAZ021' in /home/sfiala/public_html/nws-alerts.php on line 308
Fatal error: Uncaught Error: Cannot use string offset as an array in /home/sfiala/public_html/nws-alerts.php:308 Stack trace: #0 /home/sfiala/public_html/header.php(41): include_once() #1 /home/sfiala/public_html/index.php(43): include('/home/sfiala/pu...') #2 {main} thrown in /home/sfiala/public_html/nws-alerts.php on line 308
-
Hi,
I am getting that same error on same line now after going to php 7.1... "Fatal error: Uncaught Error: Cannot use string offset as an array" and made Ken's recommended changes. I saw that Curly updated script to fix, but link provided returns a 404.
-Chris
-
I was able to get Version 2.01 off his downloads site
-
Version 2.01 is a beta.
Try version 1.39
http://www.weather.ricksturf.com/scripts/nws-alerts_139.zip
-
Thanks Curly!
It seems to be bombing out on this line:
$logData[] = array($event,$cvk,$effective,$expires,$cis['icon'],$areaDesc,$abbrvDesc);
Got this error: PHP Fatal error: Uncaught Error: [] operator not supported for strings
Server is using v 7.1.4
-
I recommend adding a couple of lines of PHP temporarily to see what other (if any) issues you may have.
<?php
error_reporting (E_ALL | E_STRICT);
ini_set("display_errors", 1);
?>
I was able to clean up all the PHP 7 issues this way.
-
EDIT: nws-alerts-log.php does not work with php 7.1 due to the same issue.
Was this question ever answered directly? "PHP Fatal error: Uncaught Error: [] operator not supported for strings"
I have this error in conjunction with another script and I'm not clear on how to resolve it. This is a new issue since migrating to PHP 7.1.