WXforum.net

Web Weather => Weather Website PHP/AJAX scripting => Topic started by: mkutche on February 04, 2019, 07:17:43 AM

Title: undefined offset..
Post by: mkutche on February 04, 2019, 07:17:43 AM
any idea how to fix this??

Notice: Undefined offset: 1 in /home/hj2ke8lfpx43/public_html/forecast-summary.php on line 138

Notice: Undefined offset: 1 in /home/hj2ke8lfpx43/public_html/forecast-summary.php on line 140


here's line 138 and 140

 $discussion = $matches[1]; // now have the forecast as a string with \n delimiters

$discussion  = trim($matches[1]); // prevent extra white space at beginning and end

Thanks,
Mike
Title: Re: undefined offset..
Post by: saratogaWX on February 04, 2019, 11:11:50 AM
That undefined is caused by failure of the prior statement
Code: [Select]
preg_match('|<pre[^>]*>(.*)</pre>|Usi',$html,$matches);
It's likely due to an incomplete page fetch from the NWS site, so the area with a forecast discussion wasn't found.
Title: Re: undefined offset..
Post by: mkutche on February 06, 2019, 10:47:05 AM
That undefined is caused by failure of the prior statement
Code: [Select]
preg_match('|<pre[^>]*>(.*)</pre>|Usi',$html,$matches);
It's likely due to an incomplete page fetch from the NWS site, so the area with a forecast discussion wasn't found.

Can I hide the error??
Title: Re: undefined offset..
Post by: saratogaWX on February 06, 2019, 11:23:40 AM
Sure.. best thing to do is to turn off Notice: errata from display.

In your php.ini just put:

error_reporting = E_ALL & ~E_NOTICE
Title: Re: undefined offset..
Post by: mkutche on February 06, 2019, 09:08:22 PM
Sure.. best thing to do is to turn off Notice: errata from display.

In your php.ini just put:

error_reporting = E_ALL & ~E_NOTICE

i put that and it still shows errors hm :(